RX Fifo1 for CAN is not generating an interrupt callback (basically it is not receiving the data)

0

There are two types of messages on the CAN bus. Those are broadcast message and default message. Currently, I'm using fifo0 for both the message(which works perfectly fine). But I would like to use fifo1 specially for broadcast message. Below is my initializing code

uint8 BspCan_RxFilterConfig(uint32 filterId, uint32 filterMask, uint8 filterBankId, uint8 enableFlag, uint8 fifoAssignment)
{
    ///\todo Add method for calculating filter on the fly
    CAN_FilterTypeDef  canBusFilterConfig;
    FunctionalState filterEnableFlag = ENABLE;

    if(enableFlag == 0)
    {
        filterEnableFlag = DISABLE;
    }
    else
    {
        filterEnableFlag = ENABLE;
    }

     /*Define filter used to determine if application needs to handle message on the CAN bus or if it should
    ignore it.  If the selected rx FIFO is changed, the rx functions in this module must also be updated.
    Using mask mode with all bits set to "don't care"*/  

    canBusFilterConfig.FilterBank           = filterBankId;                                //Identification of which of the filter banks to define.  
    canBusFilterConfig.FilterMode           = CAN_FILTERMODE_IDMASK;            //Sets whether to filter out messages based on a specific id or a list
    canBusFilterConfig.FilterScale          = CAN_FILTERSCALE_32BIT;            //Sets the width of the filter, 32-bit width means filter applies to full range of std id, extended id, IDE, and RTR bits
    canBusFilterConfig.FilterIdHigh         = (0xFFFF0000 & filterId)>>16;                           //For upper 16 bits, dominant bit is expected (logic 0)
    canBusFilterConfig.FilterIdLow          = 0x0000FFFF & filterId;                           //For Lower 16 bits, dominant bit is expected (logic 0)
    canBusFilterConfig.FilterMaskIdHigh     = (0xFFFF0000 & filterMask)>>16;                           //Upper 16 bits are don't care
    canBusFilterConfig.FilterMaskIdLow      = 0x0000FFFF & filterMask;                           //Lower 16 bits are don't care
    //canBusFilterConfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;                 //Sets which rx FIFO to which to apply the filter settings
    canBusFilterConfig.FilterActivation     = filterEnableFlag;
    canBusFilterConfig.SlaveStartFilterBank           = 1;                               //Bank for the defined filter. Arbitrary value.

    if (fifoAssignment == 0)
    {
      canBusFilterConfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
    }
    else
    {
      canBusFilterConfig.FilterFIFOAssignment = CAN_FILTER_FIFO1;
    }

    //Only fails if CAN peripheral is not in ready or listening state
    if (HAL_CAN_ConfigFilter(&gCanBusH, &canBusFilterConfig) != HAL_OK)
    {
        return(ERR_CAN_INIT_FAILED);
    }
    else
    {
        return(SZW_NO_ERROR);
    }

}//end BspCan_RxFilterConfig

When initializing, fifo0 works perfectly but fifo1 doesn't. If I just initialize fifo1 for both types of messages, it doesn't generate the interrupt. What am I doing wrong over here ? How to i initialize fifo1 to make it work and generate interrupt? I also tried without using digital filters still no luck.

Thanks in advance,

embedded
stm32
fifo
can-bus
iar
asked on Stack Overflow Feb 25, 2020 by Peace9795 • edited Feb 26, 2020 by Lundin

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0