I use Atmel start and ASF4 library to generate base project and working with CAN bus on ATSAME51. All work fine without timeout (send, receive CAN messages) with base ASF4 can library function in interrupt mode. Atmel start use TX FIFO to send CAN message, and I can't change this options.
Can anyone suggest how to implement sending a CAN message with a timeout? That is, if a message cannot be transmitted within a specified period of time (automatic retransmission is enabled), the transmission is canceled. Actually, the problem is how to cancel the transmission of a message that was sent using TX FIFO but was never transmitted. The datasheet literally writes: "Transmit cancellation is not intended for Tx FIFO operation." Perhaps there is another solution, how can this be done?
Or it is worth getting away from using TX FIFO, and then, accordingly, it will not be possible to use the ASF library.
There is no way to cancel FIFO entries. That would require moving things around in the FIFO memory.
You can still use ASF4 for initialization, but you would have to implement the code for the buffer mode.
Thank you!
It looks like I found a hardcore solution, specifically for TX FIFO with a buffer length of 1 to cancel CAN transmission:
CAN1-> CCCR.bit.INIT = 1;
while (! CAN1-> CCCR.bit.INIT);
CAN1-> CCCR.bit.CCE = 1;
CAN1-> CCCR.bit.CCE = 0;
CAN1-> CCCR.bit.INIT = 0;
while (CAN1-> CCCR.bit.INIT);
In general, it is very strange that neither the ASF nor the Harmony support anything other than TX FIFO. The task is quite relevant, not all CAN messages always reach their recipients in the real world
It looks like I found a hardcore solution, specifically for TX FIFO with a buffer length of 1 to cancel CAN transmission:
There are dedicated transmit and receive buffers, I never even used the TX FIFO since I usually only send out a few messages anyways.
I do like the RX FIFO though since I can poll it in my main task with no risk of having it overflow.