Interrupts in microcontroller
This section deals with the introduction to interrupts and exceptions on microcontrollers. The main difference between both of them is interrupts have occurred when received any input on external ports and exception is used to handle instruction faults like reset or bus faults. Interrupts are used to avoid the polling method issue. In the polling method, the processor core is always checking the state of a particular pin causes wastage of clock cycles. This clock cycle can be used to perform some other operations results in an increase in efficiency of the microcontroller. When an interrupt is used to check the status of a particular pin then if the status of the pin is changed then interrupt will be activated on the processor core. So the processor will start to run particular instructions regarding this. Interrupts are asynchronous.
Exceptions are synchronous events. Exceptions are used to handle software faults like divide by zero, undefined task, and hardware faults like BusFault, MemManage, reset, etc.
1 Exception model:
Exception models are used to handle interrupts and exceptions in ARM Cortex M4F processors by using Nested Vector Interrupt Controller (NVIC). If an interrupt has occurred when a processor is executing a particular task then-current location of execution is stored in stack memory and then provides service to interrupt. After servicing interrupt it pops backs to the initial state and then resumes the ongoing task. TM4C123GH6PM microcontroller supports 78 Interrupts.
2 Exception State:
The TM4C123GH6PM microcontroller supports four exception states. These exception states handle by using Set enables, Clear enable, Set pending, Clear pending, active and priority bit register present in Nested Vector Interrupt Control. These exception states are as follows.
a. Active: It indicates that a particular exception is an active state.
b. Inactive: It indicates that the exception is not an active state or nor in a pending state.
c. Pending: It indicates that the processor is busy to service higher priority interrupt that's why lower priority interrupt is in a pending state.
d. Active and Pending: When another high priority exception is handled by the processor then low priority interrupt from the same source is kept an active and pending condition.
3 Exception Types:
Exception occurs in microcontroller have various types which are mention below.
a. Reset: Reset is a special form of exception in microcontroller with highest priority i.e. -3 (lower number highest priority). Reset is used to stop current operation of processor, and restart execution from address provided in interrupt vector table.
b. NMI:
c. Hard Fault: Hard fault is an exception occurs because of error due to exception processing
d. MemManage Fault
e. Bus Fault
f. Usage Fault
g. SVCall
h. Debug Monitor
i. PendSV
j. SysTick
k. IRQ
4.Exception Handler:
Interrupts generated on the ARM Cortex microcontroller handle by using Interrupt Service Routine, Fault Handler, and System Handler.
a. Interrupt Service Routine (ISR): When an interrupt occurs, the microcontroller calls the interrupt service routine to process an interrupt. There is a fixed location in memory that holds the address of ISR for every interrupt on the microcontroller. Refer table 2-4 for memory mapping of interrupts.
b. Fault handlers: Fault handler is used to service Hardware fault, Memory management fault, Bus fault and Usage fault.
c. System handlers: System handler is used to handle Non-maskable interrupt, PendSV, SVCall, SysTick types of exception.
5. Exception Priorities:
Comments
Post a Comment