We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
Actually I have an embedded system without keyboard in my PCB. The program is write in C and use polling for checking 8 externals periphericals but now I need to use polling only for 6 of them and so I must use external interrupt for the 2 others which are connected to ports P1.0 and P1.1 but these ports are for Keyboard Interrupt.
Can you help me please to find my way for using 2 simple externals interrupts on ports P1.0 and P1.1 instead of external Keyboard Interrupts.
My looping code is:
void micro (void) { if (!Detect_P2 && !Detect_P3 && !Detect_P4 && !Detect_P5 && !Detect_P6 && !Detect_P7 && !Detect_P8) {Mic_Mute_PA = 0x01;} else {Mic_Mute_PA = 0x00;} if (P1_0 == 0) //using it with external INTERRUPT { Unmute_PA(); //291107 pour un bon gong le faire avant d'entrer dans MicDriver_ON() mic_driver_2 ();} //Driver on else { mic_driver_off_2 (); } //Driver off if (P1_1 == 0) //using it with external INTERRUPT { Unmute_PA(); radio_on_2 ();} //RAD on else { rad_off_2 (); } //RAD off if (P3_3 == 0) {in1_on_2 ();} //IN1 on else { in1_off_2 (); } //IN1 off if (P3_4 == 0) { in2_on_2 ();} //IN2 on else { in2_off_2 (); } //IN2 off if (P3_5 == 0) {in3_on_2 ();} //IN3 on else { in3_off_2 (); } //IN3 off if (P1_2 == 0) { aux_on_2 ();} //AUX on else { aux_off_2 (); } //AUX off if (P1_3 == 0) { mic_guide_2 (); } else { mic_guide_off_2 (); } }
Thank you
Thank you Erik,
So you said me that I can use these ports for standard (not for keyboard) external interrupts so it's ok. I have twoo questions:
1) I have think about debouncing because get an interrupt when the pin goes hign and one when the pin goes low So if have good understand there will be more calling this ISR if debouncing???
I can't use hardware debouncing, so must/can I use software debouncing there for avoiding problems?
2) Like you said: DO NOT forget to take concurrent interrupts into consideration when you write the code
Because there is 8 events that can occurs with different prioritys in the main polling loop. And because I must use 2 interrupts for two events that need to be trait careffuly (one in ports P1.0 and other in P1.1) and too with priority of one of both.
Must I do something special in my software or simply must I add condition more in the if statements ?
Thank you.
Sems
my practice: NEVER check anything that can bounce in a regular interrupt, use a timer interrupt. If a regular interrupt is needed for "wake up" let that interrupt wake the chip up and do NOTHING ELSE.
re using the KBI for other purposes there are multiple potential sources of interrupt and concurrency can happen. 1) just change the match SFR only for those processed in the ISR. 2) use if .. if .. if in the ISR 3) using a switch ISR will get you to 1) 4) never use an if .. else if .. else if .. ISR.
Erik