How do we change the UART BR in runtime?
vsharma
Asked: May 21, 20222022-05-21T15:05:01+05:30 2022-05-21T15:05:01+05:30In: Microcontroller
UART
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people's questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people's questions & connect with other people.
Volt.Tech
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are basically two way to change the UART baud rate at run-time. It depends how you allocated the UART. If you allocated by PDL-method (ie. In the PSoC Creator TopDesign or Modustoolbox Device Configurator [design.modus]) then use the PDL SysClk API calls: Configure Baud Rate To get the UARTRead more
There are basically two way to change the UART baud rate at run-time. It depends how you allocated the UART.
If you allocated by PDL-method (ie. In the PSoC Creator TopDesign or Modustoolbox Device Configurator [design.modus]) then use the PDL SysClk API calls:
Configure Baud Rate
To get the UART to operate with the desired baud rate, the clk_scb frequency and the oversample must be configured. Use the SysClk (System Clock) driver API to configure clk_scb frequency. Set the oversample parameter in configuration structure to define the number of the SCB clocks within one UART bit-time.
* For clk_peri = 50 MHz, select divider value 36 and get SCB clock = (50 MHz / 36) = 1,389 MHz.
* Select Oversample = 12. These setting results UART data rate = 1,389 MHz / 12 = 115750 bps.
*/
Cy_SysClk_PeriphSetDivider (UART_CLK_DIV_TYPE, UART_CLK_DIV_NUMBER, 35UL);
Cy_SysClk_PeriphEnableDivider(UART_CLK_DIV_TYPE, UART_CLK_DIV_NUMBER);
Refer to the technical reference manual (TRM) section UART sub-section Clocking and Oversampling to get information about how to configure the UART to run with desired baud rate.
link: file:///C:/Program%20Files%20(x86)/Cypress/PDL/3.1.1/doc/pdl_api_reference_manual/html/group__group_…
If you allocated the UART by the HAL-method use:
cyhal_uart_set_baud() link: Hardware Abstraction Layer (HAL)
See less