I am using the STM32F429ZI CAN peripheral in polling TX and interrupt RX with HAL library V1.4.4 of 22-January-2016. This the procedure that I use:
- During CAN init, I call the HAL_CAN_Receive_IT to enable the first receive interrupt;
- At the end of my HAL_CAN_RxCpltCallback implementation, I call the HAL_CAN_Receive_IT to enable the next receive interrupt;
- Every 100ms in the main I call a HAL_CAN_Transmit.
Here my problem: sometimes the receive interrupt occours during HAL_CAN_Transmit execution where CAN peripheral is locked (__HAL_LOCK(hcan);). In this case the receive interrupt return a BUSY without end the receive procedure and without call the HAL_CAN_RxCpltCallback, so I can not receive other message!
Do you have some suggestion to solve this problem??
Inside HAL_CAN_Receive_IT I tried to comment the line __HAL_LOCK(hcan); e
__HAL_UNLOCK(hcan); and all is ok. This solution in my opinion is not good.
Thank you very much.