cancel
Showing results for 
Search instead for 
Did you mean: 

Hi , I am working on STM32f103zf , trying to get UART2 and UART3 to work with no success, UART1 is working ok. When I try to init UART2 I see that the the CR1 register is not being written although driver is trying to write to it and enable the UART.

ASega
Associate II

The CR1 register stays 0 (as well as CR2, it looks like all UART2 registers are 0). My first thought was that the Bus is not enabled - as UART1 is on APB2 and UART 2 and 3 are on APB1 , but I enable UART2 bus - this is the enable code :

  /* Enable GPIO */

 RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOD , ENABLE );

 /* Enable USART2 and 3*/

 RCC_APB2PeriphClockCmd( RCC_APB1Periph_USART2 | RCC_APB1Periph_USART3 | RCC_APB2Periph_AFIO, ENABLE );

What could be the reason for the CR1 register to not respond ?

Thanks

Anat

2 REPLIES 2

> RCC_APB2PeriphClockCmd( RCC_APB1Periph_USART2 | RCC_APB1Periph_USART3 | RCC_APB2Periph_AFIO, ENABLE );

You probably want to use RCC_APB1PeriphClockCmd(() for the USART clocks (and a separate command for the AFIO clock) enable.

Next time, don't forget to tell us also the STM32 model you are using.

JW

Thanks ! I missed that !