Handling interrupts
This section illustrates an approach that improves on polling. We replace the busy-wait loop and instead configure the USART peripheral to generate an interrupt signal when a new character is received by the input data register (IDR). The interrupt signal causes a special function, known as an interrupt
service routine (ISR), to be called, and this, in turn, reads the IDR and clears the interrupt signal. We illustrate this approach by a simple recipe called helloISR_c3v0.
Getting ready
Two small changes to SER_Init()
are needed to configure UART4 so that interrupts are generated when a character is received. The value written to CR1 is changed from 0x200C to 0x202C, thereby setting bit-5 (RXNEIE), and the Nested Vectored Interrupt ...
Get ARM® Cortex® M4 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.