Step 1: Polling vs Interrupt, NVIC and ISR
Polling vs Interrupt-Driven Communication
These methods are commonly used for Universal Asynchronous Receiver Transmitter (UART) communication. The polling method results in higher CPU utilization and reduced efficiency for multitasking, as the CPU continuously checks the UART status. In contrast, the interrupt-driven method allows the CPU to execute other tasks and only responds when a UART event triggers an interrupt.
| Polling Method | Interrupt-Driven Method |
|---|---|
|
|
|
|
|
|
|
|
NVIC
NVIC in the PIC32CM LS00 Curiosity Nano+ Touch Evaluation Kit efficiently manages and prioritizes UART interrupt requests, enabling the CPU to respond immediately to UART transmit or receive events without the need for continuous polling. Each UART interrupt vector is assigned a specific priority level, ensuring that critical communication events are serviced first.
The NVIC supports nested interrupts, allowing higher-priority UART interrupts to preempt lower-priority tasks. This mechanism enhances real-time performance, reduces CPU overhead, and improves system determinism in UART-based embedded applications.
ISR
ISR is a function that executes automatically when an interrupt is triggered. The NVIC manages interrupt prioritization, determining the order in which multiple interrupts are serviced. In this lab, the ISR is implemented as a callback function, which is invoked when the corresponding interrupt event occurs.
The Program Counter (PC) is a special function register that holds the address of the next instruction to be executed.
While the PC is pointing to the current instruction, if an interrupt occurs, program execution is immediately redirected to the corresponding ISR.
When an interrupt is triggered, the current PC value is pushed onto the stack, allowing the CPU to execute the ISR code.
After the ISR completes, the PC is restored from the stack, and program execution resumes from where it was interrupted.