Quantcast
Channel: Cypress Semiconductor - PSoC 4 Architecture
Viewing all articles
Browse latest Browse all 761

How to dynamically change UART baudrate

$
0
0

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
UART_Clock_Enable();
UART_1_Start();

 

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

UART_Clock_SetDividerValue(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.

 


Viewing all articles
Browse latest Browse all 761

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>