I am using IAR for flashing/debugging, and I am configuring Port 4.2 as interrupt, and this pin is connected to a switch.
When I run the first time after flashing, the interrupt comes. When I do reset using the IAR then run again, it works properly, the interrupt doesn't come until the switch is pressed.
The configuration for this pin is as following:
/* configure the push button as input interrupt pin * Enable P4.2 internal resistance as pull-Up resistance */ GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P4,GPIO_PIN2); /* set the edge of interrupt as falling edge */ GPIO_selectInterruptEdge(GPIO_PORT_P4,GPIO_PIN2,GPIO_HIGH_TO_LOW_TRANSITION); /* clear and enable the interrupt */ GPIO_clearInterrupt(GPIO_PORT_P4,GPIO_PIN2); GPIO_enableInterrupt(GPIO_PORT_P4,GPIO_PIN2);
And I do interrupt enable at the end of the initialization as following:
__bis_SR_register(GIE);
Do I need to clear port 4 interrupts at the initialization to clear any pending things?
What can cause this interrupt to be pending although the switch is not pressed?