Embedded systems and IoT

Stage 1 · Lesson 4 of 7

Pointers and memory-mapped registers

C for embedded

A is a variable holding an address. On a , addresses do not only point at RAM: each 's sit at fixed addresses listed in the reference manual, which is called memory-mapped I/O. Writing through a pointer to one of those addresses changes the hardware, for example turning a pin on.

Vendor headers wrap this in structs, so GPIOA->ODR means "the output data register of port A". Also get comfortable with pointers to buffers and arrays, pointer arithmetic, and passing pointers to functions, because drivers and DMA (hardware that copies data without the CPU) use them everywhere.

Common trapreturning a pointer to a local variable from a function: its memory is reused straight away, and the data changes under you.

A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Keep handy

Also worth your time

Mark this stage as not done?