2025-07-21 6:13 AM
I'm trying to set up CAN communication between two STM32F4 boards using CJMCU-230 transceivers, but I'm not receiving any messages. Here's a full breakdown of the setup and what I've tried:
MCU: STM32F4 Discovery (hcan1)
Transceiver: CJMCU-230
Second Node: Another STM32F4 with same configuration
Bitrate: 125 kbit/s on both ends
Termination: 120Ω termination resistor is likely present on the transceiver (CJMCU-230) board, but not manually added externally. I haven't removed or measured it directly, but many CJMCU-230 modules include onboard termination resistors by default.
GPIO, RCC, NVIC configurations are done correctly.
HAL_CAN_Start() and HAL_CAN_ActivateNotification() are called.
Transmitting messages works fine; HAL_CAN_AddTxMessage() returns HAL_OK.
No CAN message is received via CAN1 RX0 interrupt. The CAN1_RX0_IRQHandler() is never triggered.
HAL_CAN_GetRxMessage() returns HAL_ERROR when called in the main loop.
HAL_CAN_AddTxMessage() sometimes returns HAL_ERROR in the loop, but returns HAL_OK inside an external interrupt.
After sending ~9 messages, the internal hcan1.Instance->ESR register gives a value of 0x800003, which includes:
EPVF (Error Passive Flag) → CAN controller became error-passive
Transmission is no longer possible
CAN messages are sent with:
CAN filter is configured in mask mode, accepting all messages (all ID and mask bits set to 0).
CAN speed: 125 kbps on both devices.
Interrupts and NVIC configuration are properly done.
HAL_CAN_Start() and HAL_CAN_ActivateNotification() are called.
Any ideas or guidance on how to fix this would be greatly appreciated.