May 2018
Intermediate to advanced
324 pages
8h 45m
English
Development boards usually provide multiple UARTs, and our reference STM32F407 is not an exception. According to the manual, UART3 can be associated to the pins PD8 (TX) and PD9 (RX), which we will use in this example. This is the code needed to turn on the clock for the GPIO group D, and set the 8 and 9 pins in alternate mode, with an alternate function of 7:
#define AHB1_CLOCK_ER (*(volatile uint32_t *)(0x40023830))#define GPIOD_AHB1_CLOCK_ER (1 << 3)#define GPIOD_BASE 0x40020c00#define GPIOD_MODE (*(volatile uint32_t *)(GPIOD_BASE + 0x00))#define GPIOD_AFL (*(volatile uint32_t *)(GPIOD_BASE + 0x20))#define GPIOD_AFH (*(volatile uint32_t *)(GPIOD_BASE + 0x24))#define GPIO_MODE_AF (2)#define UART3_PIN_AF (7)#define ...
Read now
Unlock full access