Skip to main content

Subsection 3.3.2 Step 2: Enable the USART Clock

Just as GPIOA needed its clock enabled before we could write MODER or AFR, USART2 has its own clock that must be enabled before any of its registers can be configured. USART2’s clock is controlled by bit 17 (USART2EN) of RCC_APBENR1.
Figure 3.3.7. RCC APB peripheral clock enable register (APBENR1). The USART2EN bit (bit 17) must be set before any USART2 register can be written.
// Enable USART2 clock on the APB bus
RCC->APBENR1 |= RCC_APBENR1_USART2EN;