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:向 EtherCAT 演示代码添加 UART RX/TX 任务

Guru**** 655270 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/1133151/tmdsidk437x-adding-uart-rx-tx-tasks-to-ethercat-demo-code

器件型号:TMDSIDK437X

大家好、

我有两个单独的项目:  

项目1)使用设置为测试 UART 功能的 TI-RTOS。 该项目有2个用于 UART_RX 和 UART_TX 的任务、并使用读取回调和时钟计时器中断回显接收到的内容。 下面是附加 的 RX 任务、TX 任务、读取回调函数和时钟 ISR 函数。 此项目按预期工作

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);
}

项目2)是 EtherCAT 演示项目(PRU-ICSS-ETHERCAT_Slave_01.00.10.00)

我尝试将 UART 代码合并到 EtherCAT 演示项目中、并且在"semaphore_pend (UartClkTimeout、BIOS_wait_forever)"行运行时遇到 TX 函数使程序崩溃的问题。 如果我将 BIOS_wait_forever 更改为0、它将运行、但任务将保持运行并阻止程序的其余部分正常工作。

为什么 UART TX 任务本身工作正常、我是否缺少某些东西?但当合并到 EtherCAT 工程时、它会导致程序崩溃?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我最终解决了这个问题。 ECAT 演示代码中有一些 UART_printf 语句在 ECAT 任务初始化期间运行。 删除 UART_printf 语句后、问题不再发生。