Practice makes perfect!
Use the provided template and register an Interrupt Service Routine (ISR), statically, which toggles the LEDs on the board.
Register the ISR with the tm4c startup file (tm4c1294ncpdt_startup_c
) for a GPIO Interrupt Request (IRQ) to the port connected to the user switches.
TIPS: Don't forget to use keywords such as extern
and interrupt
, which are possibly not written in the startup code.
Use the provided template and register an Interrupt Service Routine (ISR), dynamically during runtime, which toggles the LEDs on the board.
Register the ISR with the functions provided by TivaWare for a GPIO Interrupt Request (IRQ) on the pin of the GPIO port connected to the user switches.
TIPS: Don't forget to use keywords such as extern
and interrupt
, which are possibly not written in the startup code.
Registering ISRs for button events is accompanied by an unfortune behavior. Sometimes when you press the button, the LEDs appear to not toggle at all. This happens because the switches on our board bounce when we press them, causing the ISR to be run several times. To avoid this, we have to "debounce", that is, ensure that only one digital signal can be registered within a given time until the bouncing stops.
Implement an algorithm to ensure, that the application registers only one signal in a given time. Here is possible outline of an algorithm, but you are encouraged to realize your own ideas.
- Register an ISR for IRQ (falling-edge, PORTJ) to toggle the LEDs on the board.
- In the ISR
- Disable the IRQ
- Update the value of a global variable to indicate that a button was pressed
- Toggle the LEDs
- In the main thread (while loop)
- Test if button was pressed and act only upon this event
- Test if button is not pressed and decrease counter
- Test if button is pressed (in the meantime) to reset the counter
- Test if the counter has expired to clear the current and enable future interrupts, and release the global variable indicating the button status.
- Delay/Sleep for 1ms
Reseting the counter ensures that we only clear and enable the interrupt if the button release was "stable" on consecutive cycles.
Dear sir,
Kindly share the interrupt program file to understand more about..