This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How using external interrupts instead of keyboard interrupt (KIN0:1)

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

Parents
  • 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

    Erik

Reply
  • 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

    Erik

Children
No data