Whenever a activity occurs, the activity is recognized by GPIO as an external interrupt / event.
- So what is the difference between interrupt and event ?
- When to use what ?
- And finally to implement these concepts ?
When it comes to External Interrupt/ Event, GPIO should be configured in one of the following ways:
- External Interrupt, rising edge trigger
- External Interrupt, falling edge trigger
- External Interrupt, rising & falling edge trigger
- External Event, rising edge trigger
- External Event, falling edge trigger
- External Event, rising & falling edge trigger
In case of Interrupt, ISR related to that interrupt will executed by interrupting the execution flow of program. If the WFI(Wait for Interrupt) instruction is used by CPU to enter Sleep mode, any peripheral interrupt acknowledged by the nested vectored interrupt controller (NVIC) can wake up the device from Sleep mode.
In case of Event, no ISR is executed. If the WFE(Wait for Event) instruction is used by CPU to enter Sleep mode, the MCU exits Sleep mode as soon as an event occurs.
CPU - Sleep mode, is entered by executing the WFI (Wait For Interrupt) or WFE (Wait for
Event) instructions.
In general, external event is used to
- enter an ISR, i.e. connecting line to NVIC
- toggling some bit in CORE register, to wakeup CPU
- restarting some core clock
- initiate DMA transfer etc.
Events are also generated Internal to MCU, by lets say DMA on half transfer, full transfer or error in transfer. So what event to handle and how to handle is a part of Event Management Block designer in CPU. Whats in our hand is know what all functionalities the Event management Block of MCU provided and then to configure it according to our application.
Nicely written....
ReplyDeleteThanks man. Hope it helps :)
Delete