2023-05-18 01:01 AM
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 ?
2023-05-18 01:27 AM
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?
2023-05-18 01:51 AM
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 /* */
2023-05-18 02:48 AM
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
2023-05-18 10:39 AM
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)