How to Set and Catch Interrupts

Stephen E. P. Smith · Apress eBooks · 2021

All the various iterations of the flashing LEDs program had one thing in common: they were one large loop using different methods to control the timing of the flashing. If this was part of a larger program that was doing other tasks, such as driving a robot, then putting in hooks everywhere to check if the LEDs need processing is annoying and can easily lead to bugs. Another approach is to set a timer interrupt; here, we program a timer, which, when it goes off, interrupts our program to process the LEDs. This way we don’t need a loop, nor do we need to integrate the handling of the LEDs into other parts of a larger program. In this chapter, we look at interrupts on the RP2040, how they work, and how to put them to use.

Read the paper · More papers on PaperTik