cancel
Showing results for 
Search instead for 
Did you mean: 

CAN1 Loopback mode works but Normal mode no reception with CJMCU 230

ndhan.1
Associate

I'm using two 3.3V CJMCU-230 CAN tranceiver modules to communicate between two STM32f103 bluepill boards. 

https://www.ebay.com/itm/2pcs-SN65HVD230-CJMCU-230-3-3V-CAN-Bus-Adapter-Transceiver-Module-for-Arduino-/292164476362?_ul=IN

I'm using CubeMx version STM32Cube FW_F1 V1.8.0

I'm programming CAN1 for 125K baud. A button press triggers one byte of data to be transmitted/received over CAN and on reception interrupt will be triggered.

I've same code for transmitter and receiver with the only difference that pHeader.StdId is different and sFilterConfig.FilterIdHigh is opposite id <<5.

The code works in loopback mode, but when I switch to normal mode, I do not see Rx interrupt on the receiver module.

When probed at transmitting CAN transceiver Rx and Tx signals : both seem to be same and data is correct except that there's no data on Rx or Tx of the receiving side CAN Transeiver.

My first question is why Tx and Rx pins show the same data ? Is that normal in Normal mode ?

Secondly, why reception does not work ?

I've captured output of LA shown below. I only have digital LA.

Channel 0 and 1 : TX and Rx pins of transmitting side

Channel 2 and 3 : CAN_H and CAN_L

Channel 4 and 5 : TX and Rx pins of receiving side

Any pointers what am I doing wrong here ? i've tried multiple combinations, exchanging modules, connecting common ground between the two circuits etc.

Here's my code Tx side:

pHeader.DLC=1;
  pHeader.IDE=CAN_ID_STD;
  pHeader.RTR= CAN_RTR_DATA;
  pHeader.StdId= 0x244;
 
 
  sFilterConfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
  sFilterConfig.FilterIdHigh = (0x245<<5);
  sFilterConfig.FilterIdLow = 0;
  sFilterConfig.FilterMaskIdHigh = 0;
  sFilterConfig.FilterMaskIdLow =0;
  sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
  sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
  sFilterConfig.FilterActivation  = ENABLE;
  HAL_CAN_ConfigFilter(&hcan, &sFilterConfig);
 
  HAL_CAN_Start(&hcan);
  HAL_CAN_ActivateNotification(&hcan, CAN_IT_RX_FIFO0_MSG_PENDING);

Here one on Receiving side:

pHeader.DLC=1;
  pHeader.IDE=CAN_ID_STD;
  pHeader.RTR= CAN_RTR_DATA;
  pHeader.StdId= 0x245;
 
 
  sFilterConfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
  sFilterConfig.FilterIdHigh = (0x244<<5);
  sFilterConfig.FilterIdLow = 0;
  sFilterConfig.FilterMaskIdHigh = 0;
  sFilterConfig.FilterMaskIdLow =0;
  sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
  sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
  sFilterConfig.FilterActivation  = ENABLE;
  HAL_CAN_ConfigFilter(&hcan, &sFilterConfig);
 
 
 
 
  HAL_CAN_Start(&hcan);
  HAL_CAN_ActivateNotification(&hcan, CAN_IT_RX_FIFO0_MSG_PENDING);

Common code on both thx and Rx side:

void EXTI0_IRQHandler(void)
{
 
  HAL_Delay(20);
  if(HAL_GPIO_ReadPin(Switch_GPIO_Port, Switch_EXTI_IRQn))
  {
      a++;
      HAL_CAN_AddTxMessage(&hcan, &pHeader, &a, &TxMailbox);
      HAL_Delay(1000);
 
  }
 
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
 
}
 
 
void USB_LP_CAN1_RX0_IRQHandler(void)
{
  HAL_CAN_IRQHandler(&hcan);
 
  HAL_CAN_GetRxMessage(&hcan, CAN_RX_FIFO0, &pRxHeader, &r);
 
}

0 REPLIES 0