Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 9 months ago.
Buffered CAN Messages during Interrupt context
According to the LPC17xx_User_Manual each CAN module has two receive buffers. That means that while you are reading one message, another can be received. What happens when a RX_IRQ is been handled? I've tried to read all available messages from CAN, but the maximum number of messages read is two. Shall I think that during interrupt context there are not new messages buffered?
read can messages
void CANInterruptCallBack() { NVIC_DisableIRQ(CAN_IRQn); _status = _can.read(_receivedMessage); while (_status == 1) { _buffer.queue(_receivedMessage); _status = _can.read(_receivedMessage); } NVIC_EnableIRQ(CAN_IRQn); }
Thank in advance
1 Answer
10 years, 9 months ago.
Handling your RX interrupt should be done in a very short time. Using that code it can at max read its two receive buffers, but then the read will return 0, and the function ends long before the third message arrives.
Btw disabling the interrupt isn't required, an interrupt cannot interrupt itself.
My mistake, during interrupt, I can only read one message from CAN. I've been reading the User Manual and it says that an interrupt is triggered when an message is copied to the reception buffer.
posted by Sebastian Davalle 12 Mar 2014