Embedded C is the language of small devices: thermostats, car keys, routers. Four pictures show what makes it different from ordinary programming.
A tiny computer with one job
An embedded system is a small computer built into a product to do one job. It has little memory and often no operating system, so your program controls the hardware directly.
Microcontroller, bare-metal programmingA row of light switches
Hardware is controlled through registers. Think of a register as a row of on/off switches. Each switch does something specific, such as turning on a light or starting a timer.
Registers, bitsFlip one switch, leave the rest
You almost never set the whole row at once. You use a mask to pick one switch and turn it on, off, or flip it, while leaving the others exactly as they were.
Bit masks: set, clear, toggleA doorbell beats checking the door
A program can keep checking whether something happened, or it can be told the moment it does. An interrupt is the doorbell: the chip pauses, runs a short routine, and returns to what it was doing.
Polling, interrupts, interrupt service routineWant the detail behind the pictures? See the cheat sheets and the other storyboards.
0 Comments
Post a Comment