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.

RTOS TM4C uart printf and pragma DATA_SECTION

Hello i have two questions.

I use RTOS and want to use printf with UART0. The UART works with UART_write(.... but is it also possible with printf to use the UART for stdout?

i have a array with 512 int16. but when i create the variable with "const unsigned int lambda_table[12];" it is located in the RAM. how can i locate it in the Flash? I tried to use

#pragma DATA_SECTION(lambda_table,".const")
const unsigned int lambda_table[12];

the array is now located in the flash, but the code is not working any more.??

  • Hi Franz,

    What RTOS are you using? There is an example in TI-RTOS(http://www.ti.com/tool/ti-rtos) that remaps printf output to go a UART instead. Here are main calls to make it happen. You can see the rest of the code in the uartconsole example.

    add_device("UART", _MSA, UARTUtils_deviceopen,
                   UARTUtils_deviceclose, UARTUtils_deviceread,
                   UARTUtils_devicewrite, UARTUtils_devicelseek,
                   UARTUtils_deviceunlink, UARTUtils_devicerename);

        /* Open UART0 for writing to stdout and set buffer */
        freopen("UART:0", "w", stdout);
        setvbuf(stdout, NULL, _IOLBF, 128);

        /* Open UART0 for reading from stdin and set buffer */
        freopen("UART:0", "r", stdin);
        setvbuf(stdin, NULL, _IOLBF, 128);

    Regarding the placement of the const array: you did not initialize the contents, so it cannot be a const. Try initializing the array and it should be place in flash (assuming you have .const going into flash). For example:

    const unsigned int lambda_table[12] = {0,1,2,3,4,5,6,7,8,9,0xa,0xb};

    Todd