Part Number: MSP430F5529
Other Parts Discussed in Thread: SYSBIOS
Tool/software: TI-RTOS
hi everyone,
ccsv7 for msp430;
TI-RTOS for msp43X 2.20.0.06
I run an example of TI-RTOS UART in the MSP-EXP5529LP development board, and I configure the SMCLK and MCLK clocks to 24MHZ in the Board_initGeneral() function (4M XT2 doubling via DCO)
#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTUSCIA.h>
UARTUSCIA_Object uartUSCIAObjects[MSP_EXP430F5529LP_UARTCOUNT];
const UARTUSCIA_BaudrateConfig uartUSCIABaudrates[] = {
/* {baudrate, input clock, prescalar, UCBRFx, UCBRSx, oversampling} */
{ //my add
.outputBaudrate = 115200,
.inputClockFreq = 24000000,
.prescalar = 13,
.hwRegUCBRFx = 0,
.hwRegUCBRSx = 0,
.oversampling = 1
},
{
.outputBaudrate = 115200,
.inputClockFreq = 8192000,
.prescalar = 4,
.hwRegUCBRFx = 7,
.hwRegUCBRSx = 0,
.oversampling = 1
},
{9600, 32768, 3, 0, 3, 0},
};
const UARTUSCIA_HWAttrs uartUSCIAHWAttrs[MSP_EXP430F5529LP_UARTCOUNT] = {
{
.baseAddr = USCI_A1_BASE,
.clockSource = USCI_A_UART_CLOCKSOURCE_MCLK, //#####MCLK = 24000000#####
.bitOrder = USCI_A_UART_LSB_FIRST,
.numBaudrateEntries = sizeof(uartUSCIABaudrates)/sizeof(UARTUSCIA_BaudrateConfig),
.baudrateLUT = uartUSCIABaudrates
},
};
const UART_Config UART_config[] = {
{
.fxnTablePtr = &UARTUSCIA_fxnTable,
.object = &uartUSCIAObjects[0],
.hwAttrs = &uartUSCIAHWAttrs[0]
},
{NULL, NULL, NULL}
};
void uartFxn(UArg arg0, UArg arg1)
{
UART_Handle uart;
UART_Params uartParams;
const char echoPrompt[] = "\fEchoing characters:\r\n";
// Create a UART with data processing off.
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uart = UART_open(Board_UART0, &uartParams);
if (uart == NULL) {
System_abort("Error opening the UART");
}
UART_write(uart, echoPrompt, sizeof(echoPrompt));
/* Loop forever echoing */
while (1) {
UART_write(uart, echoPrompt, sizeof(echoPrompt));
Task_sleep((unsigned int)arg0);
}
}
int main(void)
{
/* Call board init functions */
Board_initGeneral();
Board_initGPIO();
Board_initUART();
Task_Params taskParams;
Task_Params_init(&taskParams);
taskParams.arg0 = 1000;
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task0Stack;
Task_construct(&task0Struct, (Task_FuncPtr)uartFxn, &taskParams, NULL);
/* Start BIOS */
BIOS_start();
return (0);
}
when I remove the const UARTUSCIA_BaudrateConfig uartUSCIABaudrates []
{
.outputBaudrate = 115200,
.inputClockFreq = 8192000,
.prescalar = 4,
.hwRegUCBRFx = 7,
.hwRegUCBRSx = 0,
.oversampling = 1
},
and I find UART_OPEN() return ERR. I don't know why?
Similarly, when I configure MCLK to 24MHZ, I must configure my cpufrq to be a multiple of 32768 in the .CFG file to work at the UART 9600 baud rate. Someone explains why?
/* ================ Kernel (SYS/BIOS) configuration ================ */
var BIOS = xdc.useModule('ti.sysbios.BIOS');
BIOS.assertsEnabled = false;
BIOS.heapSize = 512;
BIOS.includeXdcRuntime = false;
BIOS.libType = BIOS.LibType_Custom;
BIOS.runtimeCreatesEnabled = true;
BIOS.logsEnabled = false;
BIOS.cpuFreq.hi = 0;
BIOS.cpuFreq.lo = 23986176;//32768*732
thank you!