AnsweredAssumed Answered

USART3 Clock setting is not working on STM32F334.

Question asked by Honggi Choe on Jul 20, 2017
Latest reply on Jul 26, 2017 by Zhi Gu

Hi Experts,

 

I'm a newbie to STM32F334 MCU. I need help on setting USART3 clock.

Two USARTS are used on the board. USART1 is used for PC communication. USART3 is used for BLE device communication internally.

 

PC communication was not working at first, characters were broken. USART1 was operating on default clock - PCLK - 36MHz. Changed USART1 clock to 8MHz - HSI through below API and it was working.

 

    /* Configure the HSI as USART1 clock */
    RCC_USARTCLKConfig(RCC_USART1CLK_HSI);

    /* Enable USART1 clocks */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);

 

8.4.13 Clock configuration register 3 (RCC_CFGR3)
Address: 0x30
Reset value: 0x0000 0000
Bits 19:18 USART3SW[1:0]: USART3 clock source selection
This bit is set and cleared by software to select the USART3 clock source.
00: PCLK selected as USART3 clock source (default)
01: System clock (SYSCLK) selected as USART3 clock
10: LSE clock selected as USART3 clock
11: HSI clock selected as USART3 clock

 

Bits 1:0 USART1SW[1:0]: USART1 clock source selection
This bit is set and cleared by software to select the USART1 clock source.
00: PCLK selected as USART1 clock source (default)
01: System clock (SYSCLK) selected as USART1 clock
10: LSE clock selected as USART1 clock
11: HSI clock selected as USART1 clock

 

Now similarly USART3 is not working with default clock -36MHz PCLK to BLE device.

I am trying to change USART3 clock to 8MHz HSI clock through below API.

 

    /* Configure the HSI as USART3 clock */
    RCC_USARTCLKConfig(RCC_USART3CLK_HSI);

    /* Enable USART3 clocks */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);

 

But strangely USART3SW cannot be altered to 3 from 0. I tried to change USART3SW through JTAG but it was not changed.

 

Please help me to find out why USART3SW is not changed.

Thanks a lot for your help in advance.

 

BR,

Honggi

Outcomes