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.

TMDSIDK437X: Adding UART RX/TX tasks to EtherCat demo code

Part Number: TMDSIDK437X

Hey there,

I have two separate projects: 

Project 1) using TI-RTOS that is set-up to test UART functionality. This project has 2 tasks for UART_RX and UART_TX and uses a Read callback and Clock timer interrupt to echo back what was received. Here is the attached  RX task, TX task, read callback function, and clock ISR function. This project works as expected

void UART_callback(UART_Handle handle, void *buf, size_t count)
{
    UART_osalPostLock(callbackSem);
    bufferEnd += count;
    Clock_stop(clk1Handle);
    Clock_start(clk1Handle);
}

Void UART_rx_func(UArg a0, UArg a1)
{
    int32_t recieveCount = 0;
    char tempBuf[256] = {0};
    while (1)
    {
        UART_read(uart, (void *)&UART_buffer[bufferEnd], 1);

        UART_osalPendLock(callbackSem, SemaphoreP_WAIT_FOREVER);
    }
}

Void UART_tx_func(UArg a0, UArg a1)
{
    char tempBuf[256] = {0};
    uint8_t tempInd = 0;
    while (1)
    {
        Clock_stop(clk1Handle);
        tempInd = 0;
        while(bufferStart != bufferEnd)
        {
            memcpy(&tempBuf[tempInd++], &UART_buffer[bufferStart++], 1);
        }
        UART_write(uart, (void *)tempBuf, tempInd);
        Semaphore_pend(UartClkTimeout, BIOS_WAIT_FOREVER);
    }
}

void myClk1Fxn(void)
{
    System_printf("Clk1Fxn Called\r\n");
    Semaphore_post(UartClkTimeout);
    Clock_stop(clk1Handle);
}

Project 2) Is the EtherCat demo project (PRU-ICSS-EtherCAT_Slave_01.00.10.00)

I'm trying to merge the UART code into the EtherCat demo project and I am encountering issues with the TX function crashing the program when the "Semaphore_pend(UartClkTimeout, BIOS_WAIT_FOREVER);" line runs. If I change the BIOS_WAIT_FOREVER to 0 it will run, but the task will keep running and prevent the rest of the program from working correctly.

Is there something I'm missing as to why the UART tx task works fine by itself, but when merging into the EtherCat project causes it to crash the program?