EmbeddedRelated.com
Forums
Memfault Beyond the Launch

CAN Bus Real Time Conditions

Started by Dietmar March 4, 2006
Dear Ladies and Gentlemen,

I have to develop a very safe CAN Bus application that have to resume 
its work after a short circuit on the CAN Bus in real time.

I have developed a CAN Bus Application with up to 40 CAN Bus Members 
on a Line, and it works very very well. All Controllers are Philips 
LPC2129. A few days ago, I simulated a short circuit on the CAN Bus 
lines with a duration of a few Milliseconds. All the CAN Controllers 
went into "Bus Off" State because the Transmission did not work for 
many attempts, and after them, the whole Bus was dead, also the CAN 
Analyzer with its test data (CANalyzer from Vector Informatic) that 
was on the Bus too.

The Philips LPC21xx Data Sheet tells me that after a "Bus Off" 
Condition I have to Reset the RM bit in CANMod and the CAN Controller 
will restart its work. The RXERR and TXERR Counters are in default 
state after "Bus Off", but it does not work.
May I initialize all the CAN Registers with Reset Values by Software?

At this time, the only way to re-activate the CAN Controller is to 
Reset the C (LPC2129) by a Watchdog Reset when detect RM = 1. But 
the Delay to Restart the CAN Bus after Watchdog-Reset is too long for 
my Application with this Method.

Is there anybody who has an Idea to Restart the CAN Bus after 
the "Bus Off" Condition with very short delay in Real Time?

Is there a real way to prevent the CAN Controller from "Bus Off" 
Condition?

What have I to do other than clear the RM bit in CANMOD?

Greetings

Dietmar Wengler
	

An Engineer's Guide to the LPC2100 Series

Hi Dietmar,

> The Philips LPC21xx Data Sheet tells me that after
a "Bus Off"
> Condition I have to Reset the RM bit in CANMod and the CAN Controller
> will restart its work. The RXERR and TXERR Counters are in default
> state after "Bus Off", but it does not work.

What happens to Bit 7 (BS) of CANGSR when you set RM bit?

How long does the bus error persist?
	Joel
	
Dietmar wrote:

> Dear Ladies and Gentlemen,
>
> I have to develop a very safe CAN Bus application that have to resume
> its work after a short circuit on the CAN Bus in real time.
>
> I have developed a CAN Bus Application with up to 40 CAN Bus Members
> on a Line, and it works very very well. All Controllers are Philips
> LPC2129. A few days ago, I simulated a short circuit on the CAN Bus
> lines with a duration of a few Milliseconds. All the CAN Controllers
> went into "Bus Off" State because the Transmission did not work
for
> many attempts, and after them, the whole Bus was dead, also the CAN
> Analyzer with its test data (CANalyzer from Vector Informatic) that
> was on the Bus too.
>
> The Philips LPC21xx Data Sheet tells me that after a "Bus Off"
> Condition I have to Reset the RM bit in CANMod and the CAN Controller
> will restart its work. The RXERR and TXERR Counters are in default
> state after "Bus Off", but it does not work.
> May I initialize all the CAN Registers with Reset Values by Software?
>
> At this time, the only way to re-activate the CAN Controller is to
> Reset the C (LPC2129) by a Watchdog Reset when detect RM = 1. But
> the Delay to Restart the CAN Bus after Watchdog-Reset is too long for
> my Application with this Method.
>
> Is there anybody who has an Idea to Restart the CAN Bus after
> the "Bus Off" Condition with very short delay in Real Time?
>
> Is there a real way to prevent the CAN Controller from "Bus Off"
> Condition?
>
> What have I to do other than clear the RM bit in CANMOD?
>
> Greetings
>
> Dietmar Wengler
	Can the problem be that all your nodes are in bus of and you never get 
out of it as no node send correct frames to get you out of the BusOff
 From the manual

"RM resets and disables
much of the CAN Controller. Also at this time the Transmit Error Counter 
is set to 127 and the Receive Error Counter is cleared.
Software must next clear the RM bit. Thereafter the Transmit Error 
Counter will count down 128 occurrences of the Bus Free
condition (11 consecutive recessive bits). Software can monitor this 
countdown by reading the Tx Error Counter. When this
countdown is complete, the CAN Controller clears BS and ES in CANSR, and 
sets EI in CANSR if EIE in IER is 1."

That is your nodes need to see 128 correct frames after the bus off will 
be removed after you reset the RM bit. If all your nodes are at bus off 
that will not occur.

One way to solve this is to initialize the registers of the controller 
and start again a limited number of times if you detect that you don't 
get out of bus of within a certain time. You should limit the number of 
times you allow this to happen in case your node really is faulty and to 
prevent it from disturbing an otherwise working bus.

/Ake

-- 
 ---
Ake Hedman (YAP - Yet Another Programmer)
eurosource, Brattbergavagen 17, 820 50 LOS, Sweden
Phone: (46) 657 413430 Cellular: (46) 73 0533 146
Company home: http://www.eurosource.se      
Kryddor/Te/Kaffe: http://www.brattberg.com
Personal homepage: http://www.eurosource.se/akhe
Automated home: http://www.vscp.org
	
On Sunday 05 March 2006 17:36, Ake Hedman, eurosource wrote:
> "RM resets and disables
> much of the CAN Controller. Also at this time the Transmit
> Error Counter is set to 127 and the Receive Error Counter is
> cleared. Software must next clear the RM bit. Thereafter the
> Transmit Error Counter will count down 128 occurrences of the
> Bus Free condition (11 consecutive recessive bits). Software
> can monitor this countdown by reading the Tx Error Counter.
> When this
> countdown is complete, the CAN Controller clears BS and ES in
> CANSR, and sets EI in CANSR if EIE in IER is 1."
>
> That is your nodes need to see 128 correct frames after the
> bus off will be removed after you reset the RM bit. If all
> your nodes are at bus off that will not occur.

That do not mean, that you must have correct frames at the bus. 
This means, that you must have 128x a free/unused bus for the 
time of 11 bits. If no device transmit a message, the bus is 
recessive and the time is short. If other devices send messages, 
this 11 bits are the interframe space.

But this condition is only used from the CAN controller after a 
bus off, not after a Power on.

-- 
Steffen Rose
http://www.can-cia.org/dates/events/?212
CAN Wiki http://www.CAN-Wiki.info/
	
Hi Joel, Ake, Steffen,

thank you for your Ideas.

My Application is still insufficient to detect a faulty Bus or 
faulty Node.

I fixed some Things in Software that was not quite clear to me 
before, as good as the fact that the CAN Controller must have a 
recover time between Bus Off and Restart, that means that the CAN 
Controller not simply can reset.

Nowadays, when Bus Off occurs, after clearing RM I can monitor the 
Count Down from TxErr Counter, and after them the CAN Controller 
runs properly.

Bus Off can occur 3 or 4 or 5 Times, until the CAN Controller is 
nevermore able to restart. In this case, after clearing RM, The 
TxErr Counter shows always the value 0x88, RxErr is 0, and the 
Controller is hanging.

Very strange, at this way it is not really possible to resume the 
CAN Bus Operation for at least a few specified times at a run time.

I'll try a solution on another time.

Greetings

Dietmar
	

Memfault Beyond the Launch