AnsweredAssumed Answered

CAN doesn't receive in loopback

Question asked by Tomas Zahradnik on Sep 19, 2017
Latest reply on Oct 30, 2017 by Tomas Zahradnik

Hi all,

 

I have connected CAN driver TAJ1050 to my STM32F469I-Discovery kit on extension port CN12 (pin 9 and 10). I can transmit message which is correctly received in another device (I can see this message in my PcanView).

 

Unfortunately I cannot receive any message even in loopback mode.

 

I have used source code from example in STM32Cube_FW_F4_V1.16.0 repository (CAN_Loopback example).

 

Here is relevant code:

  CAN_FilterConfTypeDef         sFilterConfig;
  static CanTxMsgTypeDef        TxMessage;
  static CanRxMsgTypeDef        RxMessage;

  hcan2.Instance = CAN2;
  hcan2.pTxMsg = &TxMessage;
  hcan2.pRxMsg = &RxMessage;
  hcan2.Init.Prescaler = 18;
  hcan2.Init.Mode = CAN_MODE_NORMAL;
  hcan2.Init.SJW = CAN_SJW_1TQ;
  hcan2.Init.BS1 = CAN_BS1_8TQ;
  hcan2.Init.BS2 = CAN_BS2_1TQ;
  hcan2.Init.TTCM = DISABLE;
  hcan2.Init.ABOM = DISABLE;
  hcan2.Init.AWUM = DISABLE;
  hcan2.Init.NART = DISABLE;
  hcan2.Init.RFLM = DISABLE;
  hcan2.Init.TXFP = DISABLE;

  if(HAL_CAN_Init(&hcan2) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler();
  }

  sFilterConfig.FilterNumber = 0;
  sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
  sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
  sFilterConfig.FilterIdHigh = 0x0000;
  sFilterConfig.FilterIdLow = 0x0000;
  sFilterConfig.FilterMaskIdHigh = 0x0000;
  sFilterConfig.FilterMaskIdLow = 0x0000;
  sFilterConfig.FilterFIFOAssignment = 0;
  sFilterConfig.FilterActivation = ENABLE;
  sFilterConfig.BankNumber = 14;

  if(HAL_CAN_ConfigFilter(&hcan2, &sFilterConfig) != HAL_OK)
  {
    /* Filter configuration Error */
    Error_Handler();
  }

  if(HAL_CAN_Receive(&hcan2, CAN_FIFO0,100) == HAL_ERROR)
  {
    /* Reception Error */
    Error_Handler();
  }

 

I'm afraid that there is some misunderstanding about filter registers because there couldn't be any HW issue while I'm in loopback mode, could be?

 

Could someone give me some hint?

Thanks for any comments.

 

Tomas

Outcomes