This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Starterware/PROCESSOR-SDK-AM335X: how to change baud rate in running time, from 115200 to 460800

Part Number: PROCESSOR-SDK-AM335X
Other Parts Discussed in Thread: AM3354

Tool/software: Starterware

hi all,

sdk -- AM335X_StarterWare_02_00_01_01

chip -- am3354

componet -- UART1

in my project,  uart1 communicates with wifi module, in the beginning , the baud rate is set as 115200, later send at cmd to set wifi module's baud rate as 460800.

now the cpu's uart1 baud rate also needs to change as 460800. i have try many times, it would not work, as following code shows.

Is there any steps for guide to changed baud rate?

void UART1_Reconfig(void) // changed to 460800
{
unsigned int divisorValue = 0;

UARTOperatingModeSelect(SOC_UART_1_REGS, UART_DISABLED_MODE);

UARTDivisorLatchEnable(SOC_UART_1_REGS);

/* Performing Baud Rate settings. */
/* Computing the Divisor Value. */
divisorValue = UARTDivisorValCompute(UART1_MODULE_INPUT_CLK,
UART1_BAUD_RATE_460800,
UART13x_OPER_MODE,
UART_MIR_OVERSAMPLING_RATE_42);

/* Programming the Divisor Latches. */
UARTDivisorLatchWrite(SOC_UART_1_REGS, divisorValue);

/* Switching to Configuration Mode B. */
UARTRegConfigModeEnable(SOC_UART_1_REGS, UART_REG_CONFIG_MODE_B);

/* Disabling write access to Divisor Latches. */
UARTDivisorLatchDisable(SOC_UART_1_REGS);

/* Switching to UART16x operating mode. */
UARTOperatingModeSelect(SOC_UART_1_REGS, UART13x_OPER_MODE);

}

void UART1_Setup(void)// initial step, baud rate is 115200
{
unsigned int fifoConfig = 0;
unsigned int divisorValue = 0;

/* Configuring the system clocks for UART1 instance. */
UART1ModuleClkConfig();

/* Performing the Pin Multiplexing for UART1 instance. */
UARTPinMuxSetup(1);

/* Performing a module reset. */
UARTModuleReset(SOC_UART_1_REGS);

/* Performing FIFO configurations. */

/* Setting the TX and RX FIFO Trigger levels as 1. No DMA enabled. */
fifoConfig = UART_FIFO_CONFIG(UART_TRIG_LVL_GRANULARITY_1,
UART_TRIG_LVL_GRANULARITY_1,
1,
1,
1,
1,
UART_DMA_EN_PATH_SCR,
UART_DMA_MODE_0_ENABLE);

/* Configuring the FIFO settings. */
UARTFIFOConfig(SOC_UART_1_REGS, fifoConfig);


/* Performing Baud Rate settings. */
/* Computing the Divisor Value. */
divisorValue = UARTDivisorValCompute(UART1_MODULE_INPUT_CLK,
UART1_BAUD_RATE_115200,
UART16x_OPER_MODE,
UART_MIR_OVERSAMPLING_RATE_42);

/* Programming the Divisor Latches. */
UARTDivisorLatchWrite(SOC_UART_1_REGS, divisorValue);


/* Switching to Configuration Mode B. */
UARTRegConfigModeEnable(SOC_UART_1_REGS, UART_REG_CONFIG_MODE_B);

/* Programming the Line Characteristics. */
UARTLineCharacConfig(SOC_UART_1_REGS,
(UART_FRAME_WORD_LENGTH_8 | UART_FRAME_NUM_STB_1),
UART_PARITY_NONE);

/* Disabling write access to Divisor Latches. */
UARTDivisorLatchDisable(SOC_UART_1_REGS);

/* Disabling Break Control. */
UARTBreakCtl(SOC_UART_1_REGS, UART_BREAK_COND_DISABLE);

/* Switching to UART16x operating mode. */
UARTOperatingModeSelect(SOC_UART_1_REGS, UART16x_OPER_MODE);

}