I have two LPC11C14 connected via can bus, terminated by 120Ohm on both ends. I also connected Logic Analyzer to scan CAN bus. I was able to send one message over the bus, without acknowledging the message on other MCU. Logic Analyzer got the message correctly. After that one message, sender got stuck on this call, after debug led toggle. So the busy flag indicates it is not busy.
... if (IS_BIT_ENABLED(LPC_CAN->IF1_CMDREQ, 15)) return; #if DEBUG LPC_GPIO3->DATA |= (1<<1); _delay_ms(200); LPC_GPIO3->DATA &= ~(1<<1); _delay_ms(200); LPC_GPIO3->DATA |= (1<<1); #endif LPC_CAN->IF1_CMDREQ &= ~(0x1f); //clear prev message number LPC_CAN->IF1_CMDREQ |= message.num; ...
Message number is incremented after each call. Also I am not sure whether IF1_CMDREQ gets reset after successful transmission, so I clear the message number before setting the new one. There is lot of time (around 600ms) between two messages.
Any idea why it gets stuck there ?
This is fixed by enabling interrupts and handling the received interrupt on both uC. Messages are sent, ACK is received.