3 Using GPIO Interrupts
This example consists of toggling the output pin value when an IOC is detected on the input pin. An interrupt can be generated by detecting a signal at the port pin that has either a rising or falling edge.
In this example, the interrupt is configured to be triggered on the falling edge of the
input signal (the value is changed from logic ‘1
’ to logic
‘0
’), in order to generate the interrupt when the button is
pressed. The interrupt routine consists of toggling the output pin value, which causes
the LED to turn on and off.
For this example, the RA0 pin is configured as input with IOC enabled on falling edge and connected to a button while the RE0 pin is configured as output and connected to an LED.
- System clock initialization
- Port initialization
- Interrupts initialization