Author Topic: Microchip SAME51 send CAN message with timeout  (Read 1015 times)

0 Members and 1 Guest are viewing this topic.

Offline chipsoftTopic starter

  • Newbie
  • Posts: 2
  • Country: ua
Microchip SAME51 send CAN message with timeout
« on: July 06, 2021, 09:34:28 am »
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.

 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11261
  • Country: us
    • Personal site
Re: Microchip SAME51 send CAN message with timeout
« Reply #1 on: July 06, 2021, 04:57:19 pm »
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.
Alex
 
The following users thanked this post: chipsoft

Offline chipsoftTopic starter

  • Newbie
  • Posts: 2
  • Country: ua
Re: Microchip SAME51 send CAN message with timeout
« Reply #2 on: July 06, 2021, 05:22:19 pm »
Thank you!

It looks like I found a hardcore solution, specifically for TX FIFO with a buffer length of 1 to cancel CAN transmission:
Code: [Select]
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 :)
 

Offline Rudolph Riedel

  • Regular Contributor
  • *
  • Posts: 67
  • Country: de
Re: Microchip SAME51 send CAN message with timeout
« Reply #3 on: July 17, 2021, 05:17:02 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf