This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems reading CAN Controller LEC in Infineon XC164CI

Hello!

In an application I have the problem of reading the contents of the TwinCAN Controller A Status Register.
Below you will see a code snipped and what the compiler creates out of it:

773:  mem=CAN_ASR;
00010C5A D7408000  EXTP     #0x0080,#1
00010C5E F2F40402  MOV      R4,DPP0:0x0204
00010C62 E4801E00  MOVB     [R0+#0x001E],RL4

mem is an integer variable, so the compiler seems to correctly move just the lower byte into the variable itself

If I unplug the CAN, the CAN_ASR is updated with the value 0x00EB, which I can see in the Peripherals and Memory Window of µVision2 when I come to the code position shown above. But when I do a single step in the code, R4 is not updated with this value. It will have 0x00E8 as contents. The lower 3 bits, which represents the LEC are missing!!
Has anybody already had problems with this??

Andreas

  • Does reading the ASR have any side effects? Like clearing the LEC?

    You say you are viewing the same location in the memory window. The debugger will have read this register before your code when single stepping if this is the case.

    Maybe that is what is happening here.

  • Hi Patrick,

    No, reading should not clear the LEC information. According to the µcontroller documentation, reading the register just clears the status change interrupt request, but this is not used in the application.

    Also, the effect described above seems to happen, if I run the application in Release configuration out of the controllers flash. Then my application tells me that an error occurred on the CAN, but the LEC information says 'No Error'

    But thanks for the suggestion!

    Andreas

  • The ASR is telling you that you are in a bus off state. The LEC will no longer be updated since the bus is disconnected.

    Is your software making use of the Error Interrupt or the Status Change Interrupt?

    An Ack Error will not cause you to go bus-off. So you need to first track down the reason for the bus-off.