cancel
Showing results for 
Search instead for 
Did you mean: 

CAN bus transmit interrupt

yang2
Associate III
Posted on June 08, 2018 at 10:55

Dear All, I have an question about CAN bus transmit interrupt. I use STM32F303.

In reference manual, it describes when transmit mailbox becomes empty, the interrupt will be triggered.

It also means of that when transmit procedure is completed, the interrupt will be triggered. right?

if yes, what should I do in the ISR(interrupt service routine)? There are no thing need to process due to the transmission is already completed. it seems like of an superfluous ISR.

#stm32 #can-bus
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on June 11, 2018 at 05:15

Hi Thomas,

Thanks your reply and time. It's useful to me.

View solution in original post

5 REPLIES 5
Thomas Rapp
Associate II
Posted on June 08, 2018 at 11:53

Hi Shunfan,

if the interrupt is useful or not of course depends on your application and architecture.

It is very often useful for applications which have to transmit more than one CAN message.

For instance if you would like to transmit a packet of a higher level protocol which has to be split in several CAN messages.

Then the hardware informs you with the CAN transmit interrupt  that the current transmission is complete and your program could proceed sending the next CAN message. What to do in the ISR to 'tell' your program this, heavily depends on your architecture, e.g. if you work on a threaded environment or have some software transmit FIFO for CAN etc.

If you gurantee that you do not want to transmit a second CAN message while onotherone is currently being transmitted or if you make sure that this is the case by polling, the interrupt is of little use (and you could then disable it).

For more information about the two paradigms of interrupts vs. polling you can refer to this article:

http://www.electronics-base.com/useful-info/software-related/90-polling-vs-interrupt

 
AvaTar
Lead
Posted on June 08, 2018 at 12:25

As I understood the RM, this interrupt is generated when the mailbox is empty, i.e. the contents has been transferred to the send hardware. This means, the physical send has only started. Depending on the baudrate, this can take long.

In the meantime, you can fill the next message into the mailbox.

Posted on June 11, 2018 at 05:15

Hi Thomas,

Thanks your reply and time. It's useful to me.

yang2
Associate III
Posted on June 11, 2018 at 05:16

I already solve my question by your explanation.

Posted on June 11, 2018 at 05:18

Hi AvaTar,

Thanks, my opinion is same as you said. Thanks your reply.