AnsweredAssumed Answered

Kinetis K22: Automatically repeat a CAN message if bus arbitration fails

Question asked by Thomas Kintzel on Feb 21, 2018
Latest reply on Mar 15, 2018 by Hui_Ma

I did setup a project for testing CAN with K22. I do use latest Processor Expert and WinIDA from iSystems.

 

Using the attached project I tested sending CAN messages. Everything worked fine until I added another node sending messages. My procedure was like this

  1. Timer Interrupt with 1 millisecond cycle time sends Message 1 using mailbox 1. Message1SentCounter++
  2. TX Buffer Free Event sends Message 2 using Mailbox 2. Message2SentCounter++

 

Both counters incremented synchronously. When I caused the second node sending cyclic messages then Message2SentCounter increments less than Message1SentCounter.

 

I checked with a CANalyzer that this was true - message 2 wasn't sent often enough. But even Message 1 was not sent es often as I expected. And this makes sense because if message 1 is not sent I won't get the TX Buffer Free Event. Please note that I tried to send 3 messages in 1 ms at a bitrate of 1 Mhz. This is more than enough time.

 

Ok, next thing I tried was checking for the error value the function. It returned ERR_BUSY and I made this to work around my problem. 

RepeatCounter = 0;
do
{
  Error = CAN1_SendFrame (CAN1_DeviceData, TransmitBuffer_Tlg_1, &Frame);
  RepeatCounter++;
}
while((Error != ERR_OK) && (RepeatCounter < 1000));

 

This works - that basically is great.

 

And here comes my questions. 

I give a message to mailbox 1. I expect that the CAN controller sends this message as soon as possible. If it can't access the bus than it should wait until the bus is empty and repeat automatically the message. If bus arbitration fails again it tries next free bus time. I do not expect that I do this by software as I did it int the above source snipped. I do not want to wast my processor time at this loop.

 

I assume that I make a configuration error. Could anybody help me with this?

 

Thank you

 

Best regards

Thomas

Attachments

Outcomes