cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Stuff Error - Acknowledge

mmetzger
Associate II
Posted on July 23, 2015 at 11:27

I have a problem with the CAN Interrupt.

My application is only listening, then I disconnect the CAN plug and get sometimes a CAN Stuff Error, this is ok, because it happens really.

I read out the error and acknowlege in the HAL_CAN_IRQHandler.

after reading the LEC bits are 0x00

only the Error Interrupt is not cleared -> ERRI is always 1. Therefore the CAN Interface generates always new interrupts and never comes back.

The only solution for the moment is to shut down the whole system by:

   HAL_NVIC_SystemReset();

inside the ErrorHandler function.

Is there really no better solution?

I tried with HAL_CAN_DeInit() but this does not clear the ERRI bit.

#stm32 #can
6 REPLIES 6
jpeacock
Associate III
Posted on July 23, 2015 at 14:03

A disconnected but enabled CAN interface is in a permanent error condition.  The error interrupt is what it's supposed to do while waiting for a remote node to connect.  You have to disable the interrupt and sleep the CAN interface to suppress the errors.

What I do when a CAN bus is disconnected is to disable the CAN interface for a period of time, enable it to see if another node is connected, and repeat until I see a remote node responding.

  Jack Peacock

mmetzger
Associate II
Posted on July 23, 2015 at 17:06

Thank's to everybody who helps in this forum.

Issue is solved!

In the error handling at the end of the HAL_CAN_IRQ routine there is missing to clear the ERRI bit.

The ERRI bit has to be cleared by writing 1 into that bit (not 0).

After this modification the CAN Interface can be disconnected and connected as you like!

Amel NASRI
ST Employee
Posted on July 24, 2015 at 13:06

Hi metzger.marco,

Which STM32Cube package are you using?

Why are you saying that ''The ERRI bit has to be cleared by writing 1 into that bit (not 0)''?

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

mmetzger
Associate II
Posted on February 29, 2016 at 13:22

Hello Mayla,

this means it is a bit strange to write a ''1'' if you want a ''0'' :-)

But it is written correctly in the manual, those who can read are in front :-)

syemets
Associate
Posted on March 25, 2016 at 17:41

Thank for idea of cleaning ERRI!

The CAN driver from CUBE is wrong and hangs out on CAN state change (SCE interrupt). Probably nobody use the driver in real CAN world :).

To clear ERRI bit one should first disable the source: for example, if EPVF is set the EPVIE should be cleared. The same for BOFF, EWGF.

Then the ERRI can be cleared by writting 1 to it.

BTW, could one show the place in manual?

syemets
Associate
Posted on March 25, 2016 at 17:46

BTW, could one show the place in manual? 

I found only:

ERRI: Error interrupt

This bit is set by hardware when a bit of the CAN_ESR has been set on error detection and

the corresponding interrupt in the CAN_IER is enabled. Setting this bit generates a status

change interrupt if the ERRIE bit in the CAN_IER register is set.

This bit is cleared by software.