Chapter 4. Inputs, Outputs, and Timers
Inputs, outputs, and timers form the basis for almost everything embedded systems do. Even the communication methods to talk to other components are made up of these (see bit-bang drivers in Chapter 7). In this chapter, I’m going to walk through a product development example. The goals will constantly change so it will feel like real life. That also lets us explore how to go from a simple system of a blinking light to debouncing buttons and dimming LEDs. Along the way, we’ll see a lot about timers and how they do much more than measure time.
However, before we get started with world domination, err, I mean product development, you need to know a bit about registers, the interface from your software to the processor.
Handling Registers
To do anything with an I/O line, we need to talk to the appropriate register. As described in “Your Processor Is a Language”, you can think of registers as an API to the hardware. Described in the chip’s user manual, registers come in all flavors to configure the processor and control peripherals. They are memory-mapped, so you can write to a specific address to modify a particular register. Often each bit in the register means something specific, which means we need to start using binary numbers to look at the values of specific bits.
Binary and Hexadecimal Math
Becoming familiar with basic binary and hexadecimal (hex) math will make your career in embedded systems far more enjoyable. Shifting individual ...