cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Bus Not Receiving Messages on STM32F4 + TJA1050 (CJMCU-230)

hamza_enes
Visitor

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:


Hardware Setup:

  • 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.


STM32 Configuration:

txHeader.DLC = 1;
txHeader.IDE = CAN_ID_STD;
txHeader.RTR = CAN_RTR_DATA;
txHeader.StdId = 0x245;
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
sFilterConfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
sFilterConfig.FilterIdHigh = 0x0000;
sFilterConfig.FilterIdLow = 0x0000;
sFilterConfig.FilterMaskIdHigh = 0x0000;
sFilterConfig.FilterMaskIdLow = 0x0000;
sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
sFilterConfig.FilterActivation = ENABLE; HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig); HAL_CAN_Start(&hcan1); HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING);
  • 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.

The Problem:

  • 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:

     
    txHeader.StdId = 0x245;
    txHeader.IDE = CAN_ID_STD;
    txHeader.RTR = CAN_RTR_DATA;
    txHeader.DLC = 1;
  • 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.

0 REPLIES 0