AnsweredAssumed Answered

HAL CAN Bus Transmission Problem

Question asked by saraf.ninad.001 on Sep 8, 2016
Latest reply on Sep 9, 2016 by FTITI.Walid
Hello,
       I am trying to send 1000 values from data stored in DMA on to CAN Bus. i am using the Data frame(8 bits each) of CAN to transmit data but i am not able to receive all the data frames. i am not able to understand what is the problem . i am using HAL Library and STM32F4_Discovery board. Have attached the CAN related code.

uint16_t IT_buffer[1000]; // buffer storing 1000 values

/*CAN Transmit*/
void CAN_Tx(void)
{
volatile     int j=0;
volatile int b=0;
     for(j=0;j<250;j++)  // each time 4values out of 1000values are send therefore 1000/4=250
         {
    //##-3- Start the Transmission process #####################################
    CanHandle.pTxMsg->StdId = 0x123;
    CanHandle.pTxMsg->RTR = CAN_RTR_DATA;
    CanHandle.pTxMsg->IDE = CAN_ID_STD;
    CanHandle.pTxMsg->DLC = 8;
    CanHandle.pTxMsg->Data[0] = (IT_buffer[b] >> 8);  
    CanHandle.pTxMsg->Data[1] = (IT_buffer[b]);          
    CanHandle.pTxMsg->Data[2] = (IT_buffer[b+1] >> 8);  
    CanHandle.pTxMsg->Data[3] = (IT_buffer[b+1]);     
    CanHandle.pTxMsg->Data[4] = (IT_buffer[b+2] >> 8);     
    CanHandle.pTxMsg->Data[5] = (IT_buffer[b+2]);          
    CanHandle.pTxMsg->Data[6] = (IT_buffer[b+3] >> 8);     
    CanHandle.pTxMsg->Data[7] = (IT_buffer[b+3]);          
    
         TransmitMailbox = HAL_CAN_Transmit(&CanHandle, 30);
         b=b+4;
        }
}

/* CAN1 init function */
void MX_CAN1_Init(void)
{
     HAL_CAN_DeInit(&CanHandle);
     static CanTxMsgTypeDef        TxMessage;
     static CanRxMsgTypeDef        RxMessage;


     /*##-1- Configure the CAN peripheral #######################################*/
            /*Baurd rate defined at 1Mhz */
            CanHandle.Instance = CAN1;
            CanHandle.pTxMsg = &TxMessage;
            CanHandle.pRxMsg = &RxMessage;

            CanHandle.Init.TTCM = DISABLE;
            CanHandle.Init.ABOM = DISABLE;
            CanHandle.Init.AWUM = DISABLE;
            CanHandle.Init.NART = DISABLE;
            CanHandle.Init.RFLM = DISABLE;
            CanHandle.Init.TXFP = DISABLE;
            CanHandle.Init.Mode = CAN_MODE_NORMAL;

            /* CAN Baudrate = 175kbps (CAN clocked at 42 MHz) */
            CanHandle.Init.SJW = CAN_SJW_1TQ;
            CanHandle.Init.BS1 = CAN_BS1_6TQ;
            CanHandle.Init.BS2 = CAN_BS2_8TQ;
            CanHandle.Init.Prescaler = 16;
            HAL_CAN_Init(&CanHandle);

}


/*CAN1 filter function*/
void CAN_filter_init(void)
{
     CAN_FilterConfTypeDef  sFilterConfig;

       /*##-2- Configure the CAN Filter ###########################################*/
     sFilterConfig.FilterNumber = 0;
    sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
    sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
    sFilterConfig.FilterIdHigh = 0x0000;//0x100 << 5;;
    sFilterConfig.FilterIdLow = 0x0000;
    sFilterConfig.FilterMaskIdHigh = 0x0000;//0x700 << 5;
    sFilterConfig.FilterMaskIdLow = 0x0000;
    sFilterConfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
    sFilterConfig.FilterActivation = ENABLE;
    sFilterConfig.BankNumber =14;
    HAL_CAN_ConfigFilter(&CanHandle, &sFilterConfig);
}

can any one help me please!!!

Outcomes