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.

CCS/MSP432P401M: Read UART to CCS console Error

Part Number: MSP432P401M

Tool/software: Code Composer Studio

Hello Team,

I have a problem what i don't understand. If read the uart and write back to CodeComposerStudio console and the uart to echo, then the UART call densely the Error callback function.
With 'fflush(stdout)' enough 4 character for the error. The console example with "12345\r\n" three times:
11
Uart Error: 32344
2311
Uart Error: 32344
211
Uart Error: 32344
2

If not fflush out evry character, it is much better. But if delay between lines less 70ms then also call Error.
For me coming densely 32344 error code. But sometimes come some other: 33196, 33180, 33168, 33188
What error code 32344 means?

I tried: with UART_MODE_CALLBACK, UART_readPolling, UART_MODE_BLOCKING, UART_read with timeout, UART_read with UART_WAIT_FOREVER

(Without the printf() the echo function working fine)

My simple Ti-RTOS code:

#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <xdc/runtime/Error.h>
#include <ti/sysbios/BIOS.h>
#include <ti/drivers/UART.h>
#include "ti_drivers_config.h"

UART_Handle uartConfig;

Semaphore_Handle SEMCONF_uart_rx;

void uartErrorCallback(uint32_t index)
{
    printf("\r\nUart Error: %d \r\n", index);
}

void UART_RX_IRQHandler(UART_Handle handle, void *buffer, size_t num)
{
    Semaphore_post(SEMCONF_uart_rx);
}

void initUart()
{
    UART_Params uartParams;
    Semaphore_Params sem_params;
    Error_Block eb;

    UART_init();

    UART_Params_init(&uartParams);

    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 115200;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readMode = UART_MODE_CALLBACK;
    uartParams.writeMode = UART_MODE_CALLBACK;
    uartParams.readCallback = &UART_RX_IRQHandler;

    uartConfig = UART_open(CONFIG_UART_0, &uartParams);

    Semaphore_Params_init(&sem_params);
    sem_params.mode = Semaphore_Mode_BINARY;

    SEMCONF_uart_rx = Semaphore_create(0, &sem_params, &eb);
}

void *uartEchohThread(void *arg0)
{
    char rxChar;

    while (1) {
        UART_read(uartConfig, &rxChar, 1);
        Semaphore_pend(SEMCONF_uart_rx, BIOS_WAIT_FOREVER);
        UART_writePolling(uartConfig, &rxChar, 1);
        printf("%c", rxChar);
        fflush(stdout);
    }
}

Thanks for any help.

Regards,
Zsolt

  • Hi Zsolt,

    That error code is displayed by uartErrorCallback(). Where is this called from? I don't see that in the code you have posted.

    Srinivas

  • Hello Srinivas,

    The errorCallbackFunction called in *.syscfg and it is work, but even without a callback, it works fals also, only to not see the result.
    *.syscfg:

    /**
     * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
     * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
     * @cliArgs --board "/ti/boards/MSP_EXP432P401R" --product "simplelink_msp432p4_sdk@3.40.01.02"
     * @versions {"data":"2020021217","timestamp":"2020021217","tool":"1.4.0+1234","templates":"2020021217"}
     */
    
    /**
     * Import the modules used in this configuration.
     */
    const RTOS  = scripting.addModule("/ti/drivers/RTOS");
    const UART  = scripting.addModule("/ti/drivers/UART");
    const UART1 = UART.addInstance();
    
    /**
     * Write custom configuration values to the imported modules.
     */
    RTOS.timer0.resource.$name = "MyTIMER_A1";
    
    UART1.$hardware             = system.deviceData.board.components.XDS110UART;
    UART1.ringBufferSize        = 64;
    UART1.interruptPriority     = "1";
    UART1.errorCallbackFunction = "uartErrorCallback";
    UART1.baudRates             = [19200,115200];
    UART1.$name                 = "CONFIG_UART_0";
    UART1.uart.$name            = "MyUART1";
    UART1.uart.$assign          = "EUSCI_A0";
    UART1.uart.txPin.$assign    = "P1.3.GPIO/EUSCI_A0_UART.TXD/EUSCI_A0_SPI.SIMO";
    UART1.uart.rxPin.$assign    = "P1.2.GPIO/EUSCI_A0_UART.RXD/EUSCI_A0_SPI.SOMI";
    
    const Power                               = scripting.addModule("/ti/drivers/Power", {}, false);
    Power.customPerformanceLevels             = 1;
    Power.initialPerformanceLevel             = 4;
    Power.advancedConfiguration               = true;
    Power.enableHFXTClock                     = true;
    Power.hfxtFrequency                       = 32000000;
    Power.lfxtDriveLevel                      = 3;
    Power.enableLFXTClock                     = true;
    Power.performanceLevel3.$name             = "ti_drivers_power_PowerMSP432PerfLevels0";
    Power.performanceLevel2.$name             = "ti_drivers_power_PowerMSP432PerfLevels1";
    Power.performanceLevel1.$name             = "ti_drivers_power_PowerMSP432PerfLevels2";
    Power.performanceLevel0.$name             = "ti_drivers_power_PowerMSP432PerfLevels3";
    Power.performanceLevel4.$name             = "ti_drivers_power_PowerMSP432PerfLevels4";
    Power.performanceLevel4.coreVoltageLevel  = "VCORE1";
    Power.performanceLevel4.flashWaitStates   = 1;
    Power.performanceLevel4.enableFlashBuffer = true;
    Power.performanceLevel4.dcoFrequency      = 48000000;
    Power.performanceLevel4.smclkDivider      = 2;
    Power.performanceLevel4.mclk              = 48000000;
    Power.performanceLevel4.hsmclk            = 48000000;
    Power.performanceLevel4.smclk             = 24000000;
    
    /**
     * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
     * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
     * re-solve from scratch.
     */
    RTOS.timer0.resource.$suggestSolution = "Timer_A0";
    

    Regards,

    Zsolt

  • Hi Zsolt,

    Are you continuously sending a byte? It is likely that the printf() + fflush() is not able to keep up with the received bytes. It could be a flow control issue. Even at 19200 baudrate, each byte takes just 500 us. This is possibly too fast for the printf(). Maybe you can put a large time delay after each byte.

    Srinivas