Hi, I'm using the IAR development kit, Olimex LPC2378-STK. I’m trying to run the CAN demo Software. But it just keep hanging here : while ( !(CAN1GSR & (1 << 3)) ); Does anyone know how to solve this problem? May thanks,
can demo
Started by ●July 9, 2008
Reply by ●July 10, 20082008-07-10
berde wrote:> Hi, > > I'm using the IAR development kit, Olimex LPC2378-STK. I’m trying to run > the CAN demo Software. But it just keep hanging here : while ( !(CAN1GSR & > (1 << 3)) ); > Does anyone know how to solve this problem? > > May thanks,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 by ●July 11, 20082008-07-11
On Wed, 09 Jul 2008 07:57:47 -0500, "berde" <joramboekhoudt@hotmail.com> wrote:>Hi, > >I'm using the IAR development kit, Olimex LPC2378-STK. I’m trying to run >the CAN demo Software. But it just keep hanging here : while ( !(CAN1GSR & >(1 << 3)) ); >Does anyone know how to solve this problem?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 by ●July 12, 20082008-07-12
Paul Keinanen wrote:> On Wed, 09 Jul 2008 07:57:47 -0500, "berde" > <joramboekhoudt@hotmail.com> wrote: > >>Hi, >> >>I'm using the IAR development kit, Olimex LPC2378-STK. I’m trying to run >>the CAN demo Software. But it just keep hanging here : while ( !(CAN1GSR & >>(1 << 3)) ); >>Does anyone know how to solve this problem? > > 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. > > PaulRegister GSR is the "Global Controller Status and Error Counters" Bit 3 contains "TCS[3] Transmit Complete Status". The manual says: 0 (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 by ●July 12, 20082008-07-12
On Sat, 12 Jul 2008 16:12:53 +0200, Heinz-J�rgen Oertel <hj.oertel@t-online.de> wrote:> >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.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