cancel
Showing results for 
Search instead for 
Did you mean: 

CAN-bus error-frame management on SMTF32F1x or SMTF32F4x

MTacc
Associate II

Using SMTF32F1x or SMTF32F4x or another, is it possible to receive/identify a generic error-frame on CAN-bus?

I'm using call back receiving and if I transmit an error-frame (I'm using Vector Canalyzer as tool), my call back is not running.

I also tried to enable HAL_CAN_ErrorCallback, but also this is never called.

What I have to do ?

4 REPLIES 4
SofLit
ST Employee

Hello,

What do you mean by "tried to enable HAL_CAN_ErrorCallback", did you activate error interrupt using HAL_CAN_ActivateNotification()? what is the interrupt error you did activate?

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.
MTacc
Associate II

Yes, the receiving of a normal frame is good, no problem.

When I transmit error frame using an external tool the call back is not called.

I writed:

 HAL_CAN_ActivateNotification(&hcan,CAN_IT_RX_FIFO0_MSG_PENDING | CAN_IT_ERROR_WARNING | CAN_IT_ERROR_PASSIVE | CAN_IT_BUSOFF | CAN_IT_LAST_ERROR_CODE | CAN_IT_ERROR);// Initialize CAN Bus Rx Interrupt

and also tried:

 HAL_CAN_ActivateNotification(&hcan,0xFFFFFFFF);// Initialize CAN Bus Rx Interrupt

I also activated:

#define USE_HAL_CAN_REGISTER_CALLBACKS     1U /* */

SofLit
ST Employee

Strange. Are you sure there was error frame asserted on the bus?

Knowing that STM32 has passed CAN conformance test. See this document:

https://www.st.com/resource/en/certification_document/stm32_authentication_can.pdf

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.
MTacc
Associate II

OK, I solved.

no need to set

#define USE_HAL_CAN_REGISTER_CALLBACKS     1U /* */

it is necessary to activate, inside CUBEMX, "CAN SCE interrupt" enabled.

After this error-frames are notified by

void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan)