can demo

Hi,

I'm using the IAR development kit, Olimex LPC2378-STK. I?m trying to ru the CAN demo Software. But it just keep hanging here : while ( !(CAN1GSR (1

Reply to
berde
Loading thread data ...

Reading the C statement, I guess the condition is always true. What is the bit 3 in register CAN1GSR telling us? Can you please look up the manual of the NXP chip.

Heinz

Reply to
Heinz-Jürgen Oertel

I hope CAN1GSR is declared as volatile.

Otherwise, an optimizing compiler might just once test that bit and if not set, go into an infinite loop.

Paul

Reply to
Paul Keinanen

Register GSR is the "Global C0 (incomplete) - At least one requested transmission has not been successfully completed yet.

I think that it can be that the transmission in his case does not finish. One reason, the CAN transceiver gets no acknowledge. A typical failure of novices. CAN is in this regard very different from sending a byte via a UART.

But of course, declaring the register as volatile is good practice.

Heinz

Reply to
Heinz-Jürgen Oertel

This might well be the case, since the OP did not say anything about what other devices there are on the bus.

If the development kit is the only device on the CAN bus, the transmitter tries over and over again to send the same message, until an other device is connected to the bus, which acknowledges the transmission.

This CANbus feature can be quite nasty if you are sending commands over CANbus and the bus is intermittent for some reason. When the bus is finally working again, a very outdated command might get through, causing various kinds of hazards. In such cases, some higher level protocol is required, e.g heartbeat messages or time tagged commands etc. Clearing the transmission queue and reseting the CAN controller chip if it appears to be stuck also reduces the risk related to delayed commands.

Paul

Reply to
Paul Keinanen

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.