cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103: HIGHER BAUD RATE FOR USART1

savas
Associate II
Posted on April 13, 2014 at 18:23

Hi all,

I have problem about setting baud rate of USART1 to 3200000 or 3686400 or 4000000. To be able to setthe higher baudrates, I revised my RCC_Configuration() as:

ErrorStatus HSEStartUpStatus;

  /* RCC system reset(for debug purpose) */

  RCC_DeInit();

  /* Enable HSE */

  RCC_HSEConfig(RCC_HSE_ON);

  /* Wait till HSE is ready */

  HSEStartUpStatus = RCC_WaitForHSEStartUp();

  if(HSEStartUpStatus == SUCCESS)

  {

     // HCLK = SYSCLK 

  RCC_HCLKConfig(RCC_SYSCLK_Div1); 

  

RCC_PCLK2Config(RCC_HCLK_Div1);

RCC_PCLK1Config(RCC_HCLK_Div1);

    FLASH_SetLatency(FLASH_Latency_2);

    FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

    // PLLCLK = 8MHz * 9 = 72 MHz 

    RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);

    RCC_PLLCmd(ENABLE);

    while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)

    {

    }

    // Select PLL as system clock source

    RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

    // Wait till PLL is used as system clock source 

    while(RCC_GetSYSCLKSource() != 0x08)

    {

    }

    

  }   

  RCC_AHBPeriphClockCmd ( RCC_AHBPeriph_DMA1 , ENABLE);

  RCC_APB2PeriphClockCmd( RCC_APB2Periph_ALL  , ENABLE);

  RCC_APB1PeriphClockCmd( RCC_APB1Periph_ALL , ENABLE);

This code works fine with baudrate=921600. But if I set the baudrate to 3200000 or higher,doesn't work properly.

Pls help me if I have any mistake.

Thanks
4 REPLIES 4
Posted on April 13, 2014 at 19:07

Higher baud rates are more difficult to hit accurately based on the nature of the divider chain. For example the 3200000 will have an error in the order of 3%. Can the connected device handle this, and have you reviewed the signal with an oscilloscope?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
savas
Associate II
Posted on April 13, 2014 at 20:08

Yes I know 3200000 is not accurate but 3686400 is more accurate. What can I do to use this baudrate?

The connected device can easily handle this baud rate, no problem. The problem is I can't use 36864000 bps. 

921600 is OK but 3686400 is problem.

Posted on April 13, 2014 at 23:24

Beyond 1 MBps, I'd honestly look at something other that async serial, also be conscious that there are some RS232 line drivers that filter at high rates.

3200000 72000000 / 22 = 3272727 2.27 % error
3200000 72000000 / 23 = 3130434 2.17 % error
3686400 72000000 / 19 = 3789473 2.80 % error
3686400 72000000 / 20 = 3600000 2.34 % error
4000000 72000000 / 18 = 4000000 0.00 % error

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
savas
Associate II
Posted on April 14, 2014 at 18:18

Thanks for your reply.