-1
\$\begingroup\$

I have a general question about CAN transmission and the acknowledgment.

I want to send multiple CAN frames (burst frames), and after I receive them all in HOST, I want to read their ack from the Bus:

My question is the following: Do I have to read the ack after each frame arrives (if this is the only way) or I can read them after the transmission ends.

For example if I send 10 consecutive CAN frames, do I will be able to read 10 ack after the transmission ends.

A practical approach when using this with an MCU with CAN transceivers : I have only two nodes : a transceiver and a receiver. Also I think using interrupts would be much useful than using polling to read the Ack

Thanks in advance

\$\endgroup\$
  • \$\begingroup\$ @Olin Lathrop Hi Mr Olin, I would be grateful if you can take a look at my question. Thanks. \$\endgroup\$ – The Beast Feb 20 '17 at 1:01
2
\$\begingroup\$

In a microcontroller, the CAN peripheral reads the ACK bit (which occurs within the frame by the way, it isn't a separate frame like in most other protocols) and will automatically resend without involving the user firmware - it runs it's own state engine because of the timing requirements. So you don't have a choice of when to handle the ACKs.

You don't necessarily get an interrupt immediately when the ACK occurs either, although you may get interrupts when the frame completes transmission successfully ie at least one node sent the ACK bit, or other conditions that occur after the frame completes or error flags are set in the CAN state engine.

\$\endgroup\$
  • \$\begingroup\$ You should have the option of enabling interrupts for transmit done interrupt or in the event of an error. If there is no ACK it will trigger an error. One other detail - Any device on the bus that's not in silent mode will send an ACK if it receives the packet. If you have a multi-device bus and want to be 100% sure that one specific device received all of the packets you'll need to add your own higher level protocol to send an packet back acknowledging the data. \$\endgroup\$ – Andrew Feb 20 '17 at 8:57
  • \$\begingroup\$ @Martin thanks for the explanation. But what I want to know is whether after sending 10 consecutive frames, Can I still receive 10 ack ? or it's just work as follow : sending one frame and receiving the Ack right away ! My final objectif is to be sure all frames have been sent successfully (arrived at the Host part). \$\endgroup\$ – The Beast Feb 20 '17 at 14:16
  • \$\begingroup\$ @Martin I agree that the interrupts will occur when the frame is sent successfully but in my case all frames arrives but the number of interrupts I get is less than expected ! I have to be sure by software that all frames are sent that's why I need to count how much ack I get (having only two nodes : one transeiver and one receiver) thanks :) \$\endgroup\$ – The Beast Feb 20 '17 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.