Changing Baud Rate on the Fly

Question: Is it possible to change the baud rate of the UART on the PSoC on the fly?

 

Answer:

Yes. It is possible to change the baud rate of the UART on the fly by changing the clock to the UART.  The UART may be clocked either by the VC1, VC2, VC3 clocks, or from a digital block like a counter. 

If a counter is used as a clock source to the UART, the period of the counter may be changed to change the baud rate of the UART by using the WritePeriod function from the Counter API.  Please refer to the API Counter_WritePeriod to learn of all the side effects. The API Counter_WritePeriod can be found in the User Module Data Sheet located within PSoC Designer.

If the UART is clocked by VC1, VC2 clocks, then the dividers may be changed by writing to the OSC_CR1 register.  If the UART is clocked by VC3, then VC3 divider may be changed by writing to the OSC_CR3 register.  The side effect of changing the VC1, VC2 or VC3 divider is that any other resource that is clocked by VC1, VC2 or VC3 will also be affected by the change in clock frequency.