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.

LP-CC1312R7: Inquiries regarding TI CC1312R7 Uart Rx issues

Part Number: LP-CC1312R7
Other Parts Discussed in Thread: CC1312R7, SYSCONFIG

Tool/software:

Hi.
I have an inquiry about Uart Rx of TI CC1312R7.

We are developing a system that transmits 42 bytes of data from Tx of another system every 100mS and receives it from TI CC1312R7 Uart.

By the way, the data is mixing when reading 42byte data from Uart Rx in CC1312R7.

I checked and it's a symptom of data mixing after 32 bytes.

What are the ways to solve this?

This is the same symptom even though the sysconfig modified the Rx ringbuffer size to 256.

  • Hi Peter,

    What SDK version are you using? I remember that we may have fixed a similar bug in our SDK some time ago...

    Regards,

    Arthur

  • We are using the version simplelink_cc13xx_cc26xx_sdk_7_41_00_17

    And, I pressed the wrong button. This issue has not been resolved.

  • Hi Peter,

    Understood.

    Is it easy for you to test with SDK 8.30, to see if the issue is still happening?

    Regards,

    Arthur

  • As you told me, I tested it with the latest SDK.
    But the problem of data mixing is the same.

    The code below is an excerpt of the Uart part of the code you are working on

    #define RX_PACKET_SIZE 42
    
    void uartStmRxCallback(UART2_Handle handle, void *buffer, size_t count, void *userArg, int_fast16_t status)
    {
    
    if (status != UART2_STATUS_SUCCESS || count == 0) {
    printf("statis is not UART2_STATUS_SUCCESS and count: %d\n", count);
    return;
    }
    
    enqueuePacket(readUart2STMBuffer);
    
    UART2_read(handle, readUart2STMBuffer, RX_PACKET_SIZE, &bytesRead);
    }
    
    void *uartStmThread(void *arg0)
    {
    UART2_Params uartParams;
    uint32_t status = UART2_STATUS_SUCCESS;
    int32_t semStatus;
    
    semStatus = sem_init(&sem, 0, 0);
    if (semStatus != 0){
    /* Error creating semaphore */
    while (1) {}
    }
    
    /* Create a UART in CALLBACK read mode */
    UART2_Params_init(&uartParams);
    uartParams.baudRate = 230400; //115200; //230400; //230400; //256000;
    uartParams.readReturnMode = UART2_ReadReturnMode_FULL;
    uartParams.writeMode = UART2_Mode_NONBLOCKING;
    uartParams.readMode = UART2_Mode_CALLBACK;
    uartParams.readCallback = uartStmRxCallback;
    uartParams.parityType = UART2_Parity_NONE;
    uartParams.dataLength = UART2_DataLen_8;
    uartParams.stopBits = UART2_StopBits_1;
    
    uartSTM = UART2_open(CONFIG_UART2_1, &uartParams);
    if (uartSTM == NULL)
    {
    /* UART2_open() failed */
    printf("uartSTM Open Faile\n");
    while (1) {}
    } // if (uart == NULL)
    
    printf("\t[recvSTM Start]\n");
    
    uartStmLoop = 1;
    stmConnectFlag = 0;
    
    UARTHEADER pUartHeader;
    uint8_t readByte = 0;
    uint32_t readDataSize = sizeof(UARTHEADER);
    
    //UART2_read(uartSTM, &pUartHeader, readDataSize, &bytesRead);
    //sem_wait(&sem);
    UART2_read(uartSTM, readUart2STMBuffer, RX_PACKET_SIZE, &bytesRead);
    //UART2_read(uartSTM, &rxByte, 1, &bytesRead);
    
    /*while(!stmConnectFlag){ //Check STM
    printf("\t\t Checking STM Connection\n");
    pUartHeader.command = CMD_CONNECT;
    uartStmWrite(&pUartHeader, readDataSize);
    ClockP_usleep(1000000);
    if(stmConnectFlag) break;
    }
    ClockP_usleep(500000);
    
    while(!stmCaptureFlag){ //Check STM
    printf("\t\t Send AudioCapture Command\n");
    pUartHeader.command = CMD_AUDIOCAPTURE;
    uartStmWrite(&pUartHeader, readDataSize);
    ClockP_usleep(1000000);
    if(stmCaptureFlag) break;
    }*/
    uint32_t readTotalSize = 0;
    while(uartStmLoop){
    uint8_t localUart2STMBuffer[RX_PACKET_SIZE];
    dequeuePacket(localUart2STMBuffer);
    uint8_t *data = (uint8_t *)localUart2STMBuffer;
    for(int i = 0; i< RX_PACKET_SIZE; i++){
    printf("data[%02d]: 0x%02x(%3d)\n", i, data[i], data[i]);
    }
    /*for (int i = 0; i < RX_PACKET_SIZE; ++i) {
    parseByte(data[i]);
    }*/
    ClockP_usleep(4000);
    }
    
    return NULL;
    }

  • Hi Peter,

    Can you also share the implementation of the enqueuePacket method?

    Regards,

    Arthur

  • #define RX_PACKET_SIZE 42
    #define PACKET_QUEUE_SIZE 250

    typedef struct {
    uint8_t data[RX_PACKET_SIZE];
    } Packet;

    typedef struct {
    Packet packets[PACKET_QUEUE_SIZE];
    volatile uint8_t head;
    volatile uint8_t tail;
    volatile uint8_t count;
    } PacketQueue;
    static PacketQueue packetQueue;

    extern void audioDataPut(void* arg);

    bool enqueuePacket(const uint8_t *data) {
    if (packetQueue.count >= PACKET_QUEUE_SIZE) return false;

    memcpy(packetQueue.packets[packetQueue.head].data, data, RX_PACKET_SIZE);
    packetQueue.head = (packetQueue.head + 1) % PACKET_QUEUE_SIZE;
    packetQueue.count++;
    return true;
    }

    bool dequeuePacket(uint8_t *outBuf) {
    if (packetQueue.count == 0) return false;

    memcpy(outBuf, packetQueue.packets[packetQueue.tail].data, RX_PACKET_SIZE);
    packetQueue.tail = (packetQueue.tail + 1) % PACKET_QUEUE_SIZE;
    packetQueue.count--;
    return true;
    }

  • Hi peter, 

    Do you have the possibility to provide a sample that reproduces the problem?

    This could be caused by the compiler wrong optimizing some stuff in the code...

    Regards,

    Arthur