cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX generated code crashed when calling HAL_CAN_Transmit_IT in timer interrput

Benjamin.Lee
Associate

Hi,

I'm using CubeMX to generate code to test my stm32f103c8 platform, but I've encountered a problem that when I put HAL_CAN_Transmit_IT in the interrupt callback function of TIM3, it then goes into Hardfault_Handler.

If I put HAL_CAN_Transmit_IT in the main loop, then everything goes well and I can successfully read the transmitted CAN data on my PC.

By debugging I can locate the crash happened at line 744 and 745 in HAL_CAN_Transmit_IT:

hcan->Instance->sTxMailBox[transmitmailbox].TDTR &= 0xFFFFFFF0U;

hcan->Instance->sTxMailBox[transmitmailbox].TDTR |= hcan->pTxMsg->DLC;

Could anyone help me to tackle this problem? Thanks.

0 REPLIES 0