2 Replies Latest reply on May 8, 2017 7:40 AM by user_1377889

    How to dynamically change UART baudrate


      Hi I am using CYBL10573-56LQXI. I have setup an UART with the SCB and I want to change the baudrate when the device is running. I have read the specification explaining how to configure the clock divider to setup the target baudrate, but I do not quite understand.


      To change the badrate dynamically, I know I need to use an external clock for the UART. By following the example in the spec:


      // Target buadrate = 115200, over-sampling = 16, HFCLK = 48MHz


      To set the frequency of the UART clock source: UART Clock = 115200 x 16 = 1.8432MHz  (So I write this in to the Clock source of the UART)

      Then Divider = HFCLK / Uart Clock = 48M / 1.8432M = 26


      Then I start the clock and UART by this:


      UART_Clock_SetDividerValue(26);    // I found the API will subtract the parameter by 1, so I do not subtract myself




      However I cannot get it work. I found that if I set the divider to 25:




      Then it will work. Why?




      Also, in this way I can only change the divider number, which cannot let me to change the buadrate dynamically, how can I change the baudrate to for example 19200 when the device is running?




      Thank you.