CAN Bus Transmit Error for TMS570LC43x board with FREERTOS

Dear all,

I am opening this topic following an error I encountered in my project using a TMS570LC43x microcontroller in a Texas Instrument development kit. I am using different peripherals for communication, including SPI and CAN. For the later one, I want to perform a cyclic transmission of data through CAN1 Broadcast, without needing of an interruption (as no request of information is expected to be received on the CAN Channel). Initially, I was sucessful on this transmittion, being able to transmit the data and read it on the output side.

I then introduced the FREERTOS task management, in order to be able to introduce the UDP Communication through an ETHERNET Port. Since then, I was no longer able to make the CAN to work, as I always encounter an error in the CAN Registers (either ACK or Form error usually in the LEC Register). I have tried to create a single task for the CAN Transmission with the highest priority, to have the CAN Transmit even before the start of the task scheduler or even to create a CRITICAL Section when performing the transmission, in case an unwanted interruption was damaging the task. However, I was not sucessful. I believe it may be related to the linker file, memory management or the initialization routine of the different microcontroller peripherals and functionalities, when comparing to the one of the code for the CAN only without FREERTOS.

I am open to any suggestions you may have that may help me solve the problem.

Thank you for your attention and help

Note interrupts won’t work between calling any FreeRTOS API functions (to create a task, for example) and starting the scheduler. See FAQ 4 on this page

Is you task running correctly if you only do something trivial in it, like flash an LED? So something like this:

void MyTestTask( void * pvParameters )
{
    for( ;; )
    {
        vTaskDelay( pdMS_TO_TICKS( 1000 );
        FlashLED();
    }
}

If so, how are you creating a delay inside the CAN task?

.

Thank you for your answer. I have three tasks running in parallel and they all work properly, including one with a LED Flashing for debug purposes. However, inside one of the tasks, where I am working with different peripherals, I have CAN transmitting messages. However, the transmission always has an error.

I tried to perform the CAN Transmission before the scheduler just to see if there was any impact but my idea is to transmit inside a task, without creating any delay. Shall I create one using vTaskDelay to make sure the transmission occurs properly?

Thank you

What is that error and can you try to find the reason of that (possibly by stepping through the code)?

vTaskDelay blocks the calling task for the specified period of time. So if you want to block your task, you can use it.

Thank you for your help. Looking at the TMS570LC43 Manual, I have had the following errors already, depending on smaller changes I perform to try and fix it :

  • Form Error: A fixed format part of a received frame has the wrong format.

  • Ack Error: The message this CAN Core transmitted was not acknowledged by another node.

  • Bit1 Error: During the transmission of a message (with the exception of the arbitration field), the device wanted to send a recessive level (bit of logical value 1), but the monitored bus value was dominant.

Any idea on where these may come from?

The vtaskDelay did not solve it however

These errors seem related to your hardware and you need to reach out to the hardware vendor for them.

You mentioned that your CAN communication works if you do not use FreeRTOS, right? Can you try to compare the code flow in both the cases and see where it diverges?