O'Reilly logo

Embedded Systems Architecture by Daniele Lacamera

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

Digital output

Enabling a digital output is possible by setting the mode to output in the mode register bits corresponding to the given pin. To be able to control the level of pin D13, which is also connected to an LED on our reference platform, we need to access the following registers:

#define GPIOD_BASE   0x40020c00#define GPIOD_MODE   (*(volatile uint32_t *)(GPIOD_BASE + 0x00))#define GPIOD_OTYPE  (*(volatile uint32_t *)(GPIOD_BASE + 0x04))#define GPIOD_PUPD   (*(volatile uint32_t *)(GPIOD_BASE + 0x0c))#define GPIOD_ODR    (*(volatile uint32_t *)(GPIOD_BASE + 0x14))#define GPIOD_BSRR   (*(volatile uint32_t *)(GPIOD_BASE + 0x18))

In later examples, alternate functions are used to change the pin assignment. The two registers containing the alternate ...

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