From 0a791f6d4bfbc755d9ca41ebafe57824ce74329d Mon Sep 17 00:00:00 2001 From: Ralf Edmund Stranzenbach Date: Tue, 14 Oct 2014 23:53:17 +0200 Subject: [PATCH] Receive may freeze if CAN saturated If either the CANBUS is saturated or the MCU is busy for some time, both RX buffers of the MCP2515 may be in use. If the MCU does not catch up in processing the incoming messages, the second message received just adds another reason for the IRQ. Thus reading a single message does not clear the IRQ conditon of the MCP2515 leading to a permanent lock up of the receiver program. Signed-off-by: Ralf Edmund Stranzenbach --- .../receive_interrupt/receive_interrupt.ino | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/examples/receive_interrupt/receive_interrupt.ino b/examples/receive_interrupt/receive_interrupt.ino index 269b4b8..22507b9 100644 --- a/examples/receive_interrupt/receive_interrupt.ino +++ b/examples/receive_interrupt/receive_interrupt.ino @@ -41,20 +41,27 @@ void MCP2515_ISR() void loop() { - if(Flag_Recv) // check if get data - { + if(Flag_Recv) { // check if get data - Flag_Recv = 0; // clear flag - CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data buf - - for(int i = 0; i