I’m using a SAME70Q21 to (among other things) interface with an ADM3053 CAN transceiver. I have already written some basic firmware which allows me to send and receive CAN packets, and have incorporated that into my existing FreeRTOS package.
At present, I use the ‘new message received’ interrupt, which is handled by an interrupt routine when a new message is appended to the CAN FIFO buffer. This works fine in my limited bench testing, but I’m concerned that generating an interrupt, and processing each individual message one at a time, will cause issues in real-world, high bandwidth applications.
As far I can see, there are 4 high-level strategies I could adopt:
Use the ‘new message’ interrupt for every received message, and process each received message as and when it is received. As per the above, this is the current approach.
Ensure the CAN FIFO buffer is sufficiently large, and use a FreeRTOS task to poll (set to a suitable frequency) the FIFO buffer for new messages, and process the received messages in batches.
A hybrid of the above two; trigger an interrupt on each ‘new message’ received in the CAN FIFO, but only increment a counter until a sufficient batch of messages has been received (or potentially a suitable amount of time has elapsed), and then process the batch using a ‘FromISR’ function (e.g. xQueueSendFromISR).
Instead of incrementing a counter with the ‘new message’ interrupt, instead use the CAN FIFO watermark interrupt, to deliver the same functionality without wasting cycles on each individual interrupt. This makes sense to me, but having already played with the watermark approach, I don’t think I fully understand the process/workflow.
I understand this isn’t necessarily a FreeRTOS-specific question, but I think it relates to general peripheral interrupt and processing strategy, so hopefully it can become a useful resource on the forum.