O'Reilly logo

Embedded Programming with the Microsoft® .NET Micro Framework by Rob Miles, Donald Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Inputs with Events

The preceding program will work well, but it is an example of polling. To monitor the state of the button, the switch continuously reads the value from the input port, meaning that the program is running at all times. This uses considerable processor time and may result in the flashlight battery draining before it has even been switched on.

A much better way to manage inputs of this kind is to use interrupts. An interrupt is initiated by a change in the state of a port. Special circuitry that generates a signal that causes the processor to pause the currently executing program and run code in an interrupt handler detects this change. Once the interrupt has been dealt with, the program will resume execution.

In conventional embedded ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required