CAN error handling

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAN error handling

1,164 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xander.houtman on Sun Feb 22 09:03:11 MST 2015
Dear LPC community,

While implementing some software that uses the CAN bus I figured out that there are a lot of interrupt and status bits related to errors on the bus. Figuring it would be useful to log some of these error and maybe let the software act differently when it seems the CAN cable is not connected at all, I started puzzling.

The software will run on the LPC175x/6x series so I started at the user manual ( http://www.nxp.com/documents/user_manual/UM10360.pdf ). Unfortunately the user manual only describes the registers related to the interrupts and status bits with a brief, one line, explanation for each bit, instead of an extensive explanation of the system as a whole. So next up was the Bosch specification of CAN2.0 ( http://esd.cs.ucr.edu/webres/can20.pdf ). This document describes the three states of a CAN controller. It also hints to the error count warning limit of 96, for which there seems to be an implementation in the LPC175x/6x series. But the Bosch specification obviously does not specify how to detect these states on a LPC175x/6x series controller.

However, when putting the documents next to each other, things only more confusing for me. For example: is the "Error warning" interrupt fired when the controller enters the "Error passive" state? The CAN Interrupt Enable Register EIE bit description states it does, but the CAN Interrupt and Capture Register EI bit description states it only happens when the 'Error Status' bit of the Status Register is set. The 'Error Status' of the Status Register equals the error bit of the Global Status Register, which in turn is set when the Error Warning Limit ( 96 by default ) is violated, not when the CAN controller enters the 'Error passive' state.

As you may have deducted from the above example, I'm a bit lost in the documentation due to the amount of references and terminology.
My question is therefore: Is there a document that properly explains how all the registers and interrupts of the LPC175x/6x series relate to the state machine of the CAN controller? If not: can someone explain this?
The explanation should answer questions like: "How do I determine the current state of the CAN controller?" and "When the CAN controller enters state X, what interrupt is fired, and how do I distinguish the scenario from other scenario's where the interrupt is fired (such as leaving the same state)?".
Labels (1)
0 Kudos
Reply
0 Replies