Part Number: MSPM0G3507
Other Parts Discussed in Thread: SYSCONFIG
Tool/software:
Hi all,
I am completely new to programming MCU's and am stuck on UART. I have followed the "uart_echo_interrupts_standby_LP_MSPM0G3507_nortos_ticlang" example and deconstructed it from higher level macros to something that I can understand. My code and the example code look exactly the same except for the two "ti_msp_dl_config.h" files. That seems to be the difference maker but I can't change that file. Can someone please tell me where I am going wrong with configuring UART? I posted my code below.
#include "ti_msp_dl_config.h"
static const DL_UART_Main_ClockConfig gUART_0ClockConfig = {
.clockSel = DL_UART_MAIN_CLOCK_LFCLK,
.divideRatio = DL_UART_MAIN_CLOCK_DIVIDE_RATIO_1
};
static const DL_UART_Main_Config gUART_0Config = {
.mode = DL_UART_MAIN_MODE_NORMAL,
.direction = DL_UART_MAIN_DIRECTION_TX_RX,
.flowControl = DL_UART_MAIN_FLOW_CONTROL_NONE,
.parity = DL_UART_MAIN_PARITY_NONE,
.wordLength = DL_UART_MAIN_WORD_LENGTH_8_BITS,
.stopBits = DL_UART_MAIN_STOP_BITS_ONE
};
volatile uint8_t gEchoData = 0;
int main(void)
{
//SYSCFG_DL_init()
DL_GPIO_reset(GPIOA);
DL_GPIO_reset(GPIOB);
DL_UART_reset(UART0);
DL_GPIO_setPins(GPIOA, DL_GPIO_PIN_10 | DL_GPIO_PIN_11);
DL_GPIO_enableOutput(GPIOA, DL_GPIO_PIN_10);
DL_GPIO_enablePower(GPIOA);
DL_GPIO_enablePower(GPIOB);
DL_UART_enablePower(UART0);
DL_GPIO_initPeripheralOutputFunction(IOMUX_PINCM21, IOMUX_PINCM21_PF_UART0_TX);
DL_GPIO_initPeripheralInputFunction(IOMUX_PINCM22, IOMUX_PINCM22_PF_UART0_RX);
DL_GPIO_initDigitalOutput(IOMUX_PINCM1);
DL_GPIO_initDigitalOutput(IOMUX_PINCM37);
DL_GPIO_setPins(GPIOA, DL_GPIO_PIN_0 | DL_GPIO_PIN_15);
DL_GPIO_enableOutput(GPIOA, DL_GPIO_PIN_0 | DL_GPIO_PIN_15);
/* Module-Specific Initializations*/
DL_UART_setClockConfig(UART0, (DL_UART_Main_ClockConfig *) &gUART_0ClockConfig);
DL_UART_init(UART0, (DL_UART_Main_Config *) &gUART_0Config);
/*
* Configure baud rate by setting oversampling and baud rate divisors.
* Target baud rate: 9600
* Actual baud rate: 9576.04
*/
DL_UART_setOversampling(UART0, DL_UART_OVERSAMPLING_RATE_3X);
DL_UART_setBaudRateDivisor(UART0, 1, 9);
/* Configure Interrupts */
DL_UART_enableInterrupt(UART0,DL_UART_INTERRUPT_RX);
DL_UART_enable(UART0);
DL_GPIO_enableOutput(GPIOA, DL_GPIO_PIN_10);
NVIC_ClearPendingIRQ(UART0_INT_IRQn);
NVIC_EnableIRQ(UART0_INT_IRQn);
DL_SYSCTL_enableSleepOnExit();
while (1) {
__WFI();
}
}
void UART_0_INST_IRQHandler(void)
{
switch (DL_UART_getPendingInterrupt(UART0)) {
case DL_UART_IIDX_RX:
DL_GPIO_togglePins(GPIOA,DL_GPIO_PIN_0 | DL_GPIO_PIN_15);
gEchoData = DL_UART_receiveData(UART0);
DL_UART_transmitData(UART0, number);
break;
default:
break;
}
}