AnsweredAssumed Answered

[BUG CubeMX HAL] STM32F373 CAN RxMessage->FIFONumber not set?

Question asked by Valentin on May 10, 2016
Latest reply on Sep 19, 2016 by Valentin
Hi,

I'm testing receiving CAN messages using FIFO #1 at the moment and it all works fine, except that the field hcan->pRxMsg->FIFONumber isn't set.

Background:
I set up can filter bank 0 in list mode using this code:
 
        CAN_FilterConfTypeDef sFilterConfig;
        sFilterConfig.FilterNumber = 0;
        sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
        sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
        sFilterConfig.FilterIdHigh = (can_id << 21) >> 16; // place STD_ID in bits 19:31, EXT_ID in bits 3:31
        sFilterConfig.FilterIdLow = (can_id << 21);
        sFilterConfig.FilterMaskIdHigh = 0x0000; //FR2 is empty, set to 0
        sFilterConfig.FilterMaskIdLow = 0x0000; //FR2 is empty, set to 0
        sFilterConfig.FilterFIFOAssignment = CAN_FIFO1; //=1
        sFilterConfig.FilterActivation = ENABLE;
        sFilterConfig.BankNumber = 26; // irrelevant if only using one can controller.

        if (HAL_CAN_ConfigFilter(canhandle, &sFilterConfig) != HAL_OK) {
            static uint8_t error = 0;
            error++;
        }

And the interrupt fires up correctly (CAN_RX1_IRQHandler) but when tracing from there until HAL_CAN_RxCpltCallback() the value of hcan->pRxMsg->FIFONumber is still 0, even though it SHOULD be 1, shouldn't it?

I suggest fixing this by adding the following line to the start of
static HAL_StatusTypeDef CAN_Receive_IT(CAN_HandleTypeDef* hcan, uint8_t FIFONumber){
hcan->pRxMsg->FIFONumber = FIFONumber;

... rest of function
}

This works for me.

Outcomes