AnsweredAssumed Answered

CAN is getting stuck in initilaztion

Question asked by hobb.epy on Sep 27, 2016
Latest reply on Sep 27, 2016 by hobb.epy
Hi,
I m using STM32F303XC processor.
I configured the CAN at 250 kbps baud rate. but it is getting stuck in following while loop. CAN is not able initialize properly.
What would be the problem to getting stuck in initialisation.


[CODE]
  /* Request initialisation */
  SET_BIT(hcan->Instance->MCR, CAN_MCR_INRQ);


  /* Get timeout */
  tickstart = HAL_GetTick();   
  
  /* Wait the acknowledge */
  while(HAL_IS_BIT_CLR(hcan->Instance->MSR, CAN_MSR_INAK))
  {
    if((HAL_GetTick()-tickstart) > CAN_TIMEOUT_VALUE)
    {
      hcan->State= HAL_CAN_STATE_TIMEOUT;


      /* Process unlocked */
      __HAL_UNLOCK(hcan);


      return HAL_TIMEOUT;
    }
  }
[/CODE]


here is my CAN configuration.
[CODE]
     hcan.Instance = CAN1;
     hcan.Init.Prescaler = 16;                    //250 kbps baud rate.
     hcan.Init.Mode = CAN_MODE_LOOPBACK;
     hcan.Init.SJW = CAN_SJW_1TQ;
     hcan.Init.BS1 = CAN_BS1_5TQ;
     hcan.Init.BS2 = CAN_BS2_2TQ;
     hcan.Init.TTCM = DISABLE;
     hcan.Init.ABOM = DISABLE;
     hcan.Init.AWUM = DISABLE;
     hcan.Init.NART = DISABLE;
     hcan.Init.RFLM = DISABLE;
     hcan.Init.TXFP = DISABLE;
[/CODE]

Outcomes