AnsweredAssumed Answered

Changes required in the CAN configurations for stm32f413xx, since the below configurations in the code is not working

Question asked by Gautham Y.T on Dec 8, 2017
Latest reply on Dec 14, 2017 by Gautham Y.T

void MXCAN1Init(void)

{

    __HAL_RCC_CAN1_CLK_ENABLE();

    stat_stCAN_HandleTypeDefHCan1.Instance = CAN1;

    //stat_stCAN_HandleTypeDefHCan1.Init.Prescaler = (U16)((U32)HAL_RCC_GetPCLK1Freq() /

    //                                                     (16U * CAN_BAUD_RATE_BPS));

    stat_stCAN_HandleTypeDefHCan1.Init.Prescaler = 16;

    stat_stCAN_HandleTypeDefHCan1.Init.Mode = CAN_MODE_NORMAL;

    stat_stCAN_HandleTypeDefHCan1.Init.SJW = CAN_SJW_1TQ;

    //stat_stCAN_HandleTypeDefHCan1.Init.BS1 = CAN_BS1_8TQ;

    stat_stCAN_HandleTypeDefHCan1.Init.BS1 = CAN_BS1_6TQ;

    //stat_stCAN_HandleTypeDefHCan1.Init.BS2 = CAN_BS2_7TQ;

    stat_stCAN_HandleTypeDefHCan1.Init.BS2 = CAN_BS2_8TQ;

    stat_stCAN_HandleTypeDefHCan1.Init.TTCM = (U32)DISABLE;

    stat_stCAN_HandleTypeDefHCan1.Init.ABOM = (U32)DISABLE;

    stat_stCAN_HandleTypeDefHCan1.Init.AWUM = (U32)DISABLE;

    stat_stCAN_HandleTypeDefHCan1.Init.NART = (U32)DISABLE;

    stat_stCAN_HandleTypeDefHCan1.Init.RFLM = (U32)DISABLE;

    stat_stCAN_HandleTypeDefHCan1.Init.TXFP = (U32)DISABLE;

    if (HAL_CAN_Init(&stat_stCAN_HandleTypeDefHCan1) != HAL_OK)

    {

        ErrorHandler();

    }

}

Outcomes