Peripherals
A microcontroller is a processor on a silicon designed with additional peripherals that communicates together through a System and Peripheral Bus.
Microcontroller Architecture - The Definitive Guide to ARM Cortex -M3 and Cortex -M4 Processors
Configuration and setup
Peripherals are specialized electronic components that are configured and used through memory mapped register (address). Those peripheral configuration and register are provided by the microcontroller manufacturer in the MCU’s datasheet.
Memory Mapped Registers
(Thorough this course we will be referencing the datasheet and reference manual of the STM32L412KB MCU and the Nucleo-L412KB board. You can find them on the st.com website, and directly at these links: stm32l412kb_datasheet.pdf, stm32l412kb_reference_manual.pdf)
| Global Memory Mapping | Precise Register Boundaries |
|---|---|
![]() | ![]() |
As we can see, for this MCU, the Peripherals registers start in the memory area of 0x4000_0000 and for specifically the Peripheral called I2C1 (which means its the first peripheral of type I2C on this chip, we will see more about this in the I2C chapter) at the address 0x4000_5400 and ends at 0x4000_57FF in the APB1 Bus/Register.
Alternate Functions
Some peripherals are accessible through alternate functions of GPIO pin (cf GPIO chapter).
Alternate function list of Port B GPIOs - stm32l412kb datasheet
In this page, lets take an example with the pin PB0 of the Port B. By reading the table we are able to know that this pin can be configured in order to be either TRACED0 as part of the SYS_AF (System Alternate Function), either TIM1_CH2N (for “Timer 1 Chanel 2”) of the Tim1(Timer 1)/Tim2(Timer 2) peripherals, either SPI1_NSS (NSS component of the SPI protocol that we will see in another chapter) of SPI1/SPI2 peripherals, either USART3_CK of peripheral USART1/USART2/USART3.
So what does it mean? It means that for 1 physical pin, we can, through the firmware configuration, select from multiple possible function for that pin. It can have only 1 function at a time and different pins can point to the same function (however always configure only 1 function to 1 pin).
Each peripheral in the list we discussed above might need several different functions in order to operate, hence you will have to configure pins with different functions corresponding to the same peripheral name. As an example that we will detail later, in order to operate a SPI peripheral, you will need to configure for SPIx (where x is your SPI peripheral number) the functions SPIx_NSS, SPIx_SCK, SPIx_MISO and SPIx_MOSI.
As for what “is” a pin? Its actually one of the many little metal leg that is coming out of your chip. For instance, for the STM32L412KB in its LQFP64 package (the package of a chip is the type of packaging/form it comes in, like the physical layout, shape and size of it), the PB0 pin we were talking about is located here, on leg 26:


