cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Cube CAN Driver locks up with bus errors

jesper
Associate II
Posted on June 01, 2015 at 19:28

I am using a STM32F072, code generated by CubeMx 4.7.1 with F/W 1.2.1

My CAN code looks exactly like the Example code in ...\STM32Cube_FW_F0_V1.2.0\Projects\STM32072B_EVAL\Examples\CAN

My device is connected to a very long CAN-bus which does have some signal integrity issues due to the length of cabling. But the driver should be able to handle this and recover from errors, I would hope. But it does not.

When there is an error on the bus CEC_CAN_IRQHandler() > HAL_CAN_IRQHandler() gets called, but the latter fails to clear the ERRI interrupt properly, resulting in the device looping in calling these two routines, and thus locking up.

I have solved this temporarily by not letting HAL_CAN_Receive_IT() enable the ERRI interrupt, which at least stops the device from locking up and allows it to continue operating.

But I don't think it is meant to work this way ;-)

/jesper

#bxcan #stm32cube
1 REPLY 1
Posted on June 03, 2015 at 11:29

We have the same problem. The problem arises when we have multiple devices connected and they start sending at the same time.

We start receiving the messages correctly on the microchip can bus analyzer software. But after that all devices hang in a loop on HAL_error_callback(). It hangs because of an continuous interrupt that will not be cleared.

We have tested to reinitiate CAN in error_callback and the interrupt still execute. We have tried to clear all pending error interrupt without success.

If we increase the speed (from 125kbps to 500kbps) the problem is less likely to appear, but still does.

We have terminated both ends of the can bus.

What about TTCM, ABOM, AWUM, NART, RFLM, TXFP. Are we missing to set these to enable? We have all disabled atm.