Tool/software: Code Composer Studio
Hello everyone, I am trying to send a string of data through the UART using the printf function. You can find the printf function here: "http://www.msp430launchpad.com/2012/06/using-printf.html".
/* DriverLib Includes */ #include "driverlib.h" /* Standard Includes */ #include <stdint.h> #include <stdbool.h> #include <printf.h> /* UART Configuration Parameter. These are the configuration parameters to * make the eUSCI A UART module to operate with a 9600 baud rate. These * values were calculated using the online calculator that TI provides * at: *software-dl.ti.com/.../index.html */ const eUSCI_UART_Config uartConfig = { EUSCI_A_UART_CLOCKSOURCE_SMCLK, // SMCLK Clock Source 78, // BRDIV = 78 2, // UCxBRF = 2 0, // UCxBRS = 0 EUSCI_A_UART_NO_PARITY, // No Parity EUSCI_A_UART_LSB_FIRST, // LSB First EUSCI_A_UART_ONE_STOP_BIT, // One stop bit EUSCI_A_UART_MODE, // UART mode EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION // Oversampling }; int main(void) { /* Halting WDT */ MAP_WDT_A_holdTimer(); /* Selecting P1.2 and P1.3 in UART mode */ MAP_GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P1, GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3, GPIO_PRIMARY_MODULE_FUNCTION); /* Setting DCO to 12MHz */ CS_setDCOCenteredFrequency(CS_DCO_FREQUENCY_12); /* Configuring UART Module */ MAP_UART_initModule(EUSCI_A0_BASE, &uartConfig); /* Enable UART module */ MAP_UART_enableModule(EUSCI_A0_BASE); /* Enabling interrupts */ MAP_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT); MAP_Interrupt_enableInterrupt(INT_EUSCIA0); MAP_Interrupt_enableSleepOnIsrExit(); MAP_Interrupt_enableMaster(); /* Initialize values to display */ char *s = "printf test"; char c = '!'; int i = -12345; unsigned u = 4321; long int l = -123456780; long unsigned n = 1098765432; unsigned x = 0xABCD; while(1) { printf(EUSCI_A0_BASE, "String %s\r\n", s); printf(EUSCI_A0_BASE, "Char %c\r\n", c); printf(EUSCI_A0_BASE, "Integer %i\r\n", i); printf(EUSCI_A0_BASE, "Unsigned %u\r\n", u); printf(EUSCI_A0_BASE, "Long %l\r\n", l); printf(EUSCI_A0_BASE, "uNsigned loNg %n\r\n", n); printf(EUSCI_A0_BASE, "heX %x\r\n", x); } } /* EUSCI A0 UART ISR - Echoes data back to PC host */ void EUSCIA0_IRQHandler(void) { uint32_t status = MAP_UART_getEnabledInterruptStatus(EUSCI_A0_BASE); MAP_UART_clearInterruptFlag(EUSCI_A0_BASE, status); if(status & EUSCI_A_UART_RECEIVE_INTERRUPT) { MAP_UART_transmitData(EUSCI_A0_BASE, MAP_UART_receiveData(EUSCI_A0_BASE)); } }
I am only receiving data when sending a single word "a" or numbers (integers). Nothing appears when I am trying to send a string "something".
I am getting some warnings when building the file:
- #1532-D (ULP 5.3) Detected printf() operation(s). Recommend moving them to RAM during run or not using as these are processing/power intensive.
- #154-D conversion on nonzero integer to pointer .
- #169-D argument of type "unsigned int" is incompatible with parameter of type of type char "char *" .
I can run the code but nothing appears on my terminal (on COM5).