How to set a GPIO Interrupt, for pin PIEE0 in MC9S12XEG384

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to set a GPIO Interrupt, for pin PIEE0 in MC9S12XEG384

598 Views
vijay4
Contributor I

How to set a GPIO Interrupt, for pin PIEE0 , IN MC9S12XEG384 Freescale controller.

Tags (1)
0 Kudos
Reply
1 Reply

510 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

PTE_ E0 is an \XIRQ interrupt which in non maskable locally.

XIRQ must be enabled in the CCR register. Moreover I suggest to use external pull up resistors, to avoid influence of disturbing,  because internal are weak.


Behavior in the low power mode: The event at this pin is able to wake up the MCU from stop/pseudo stop mode. If interrupt is enabled then code continues  in the interrupt subroutine and then after instruction STOP, otherwise, when XIRQ is not enabled the code continues after event at the pin  directly at the first instruction after STOP instruction.

void main(void)
{
  //----------------------------------------
  PUCR_PUPEE = 1;                           // pull-up on XIRQ, external 4.7k ~ 10k is also recommended
  //----------------------------------------
  // CCR register:    S X H I   N Z V C // look into S12XCPUV2 reference manual
  //----------------------------------------
  asm andcc #0xBF;                          // enable XIRQ interrupt CCR=CCR & 1011 1111
                                                           // there is no way to disable XIRQ if enabled
  //----------------------------------------
  //  asm CLI;                                    // global enable I-bit maskable interrupts
                                                         // or another way: asm andcc #0xEF; //CCR=CCR & 1110 1111
  //----------------------------------------
  //  asm andcc #0x7F;                     // enable asm STOP instruction recognition CCR=CCR & 0111 1111
  //----------------------------------------
  for(;;)
   {
    asm nop;
  }
  //----------------------------------------
}
//==============================================================================
// it jumps to \XIRQ interrupt while \XIRQ is 0
//==============================================================================
#pragma CODE_SEG NON_BANKED

interrupt 5 void XIRQisr(void)  // or interrupt ((0xFE-0xF4)/2) void XIRQisr(void)
{
  // put your code here
}
#pragma CODE_SEG DEFAULT
//==============================================================================

Best regards,

Ladislav

0 Kudos
Reply