STM32F439 Issue with CAN Recieve using both FIFOs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-02-06 11:17 AM
Hi,
I have a weird issue happening in my code related to CAN Receive. I have 2 filters set up to each pass a single Message:
void FilterSetup(void)
{ CAN_FilterConfTypeDef sFilterConfig;uint32_t EXTID = 0x0CF0040A;
sFilterConfig.FilterNumber = 0; sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK; sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT; sFilterConfig.FilterIdHigh = (EXTID >> 13) & 0xFFFF; sFilterConfig.FilterIdLow = ((EXTID << 3) & 0xFFF8) | 4; sFilterConfig.FilterMaskIdHigh = 0xFFFF; sFilterConfig.FilterMaskIdLow = 0xFFFC; sFilterConfig.FilterFIFOAssignment = CAN_FIFO0; sFilterConfig.FilterActivation = ENABLE; sFilterConfig.BankNumber = 9;if(HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig) != HAL_OK)
{ Error_Handler(); }uint32_t EXTID1 = 0x18F003F8;
sFilterConfig.FilterNumber = 1;
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK; sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT; sFilterConfig.FilterIdHigh = (EXTID1 >> 13) & 0xFFFF; sFilterConfig.FilterIdLow = ((EXTID1 << 3) & 0xFFF8) | 4; sFilterConfig.FilterMaskIdHigh = 0xFFFF; sFilterConfig.FilterMaskIdLow = 0xFFFC; sFilterConfig.FilterFIFOAssignment = CAN_FIFO1; sFilterConfig.FilterActivation = ENABLE; sFilterConfig.BankNumber = 10;if(HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig) != HAL_OK)
{ Error_Handler(); }}When I run my code I see the following behavior:
- Using a PCAN tool, I send my 0x18F003F8 message to the MCU. This works fine and i see the message was received in FIFO1.
- Using a PCAN tool, I send my 0x0CF0040A message to the MCU. This also works fine and I see the message received in FIFO0.
- If I send 0x0CF0040A first (receives in FIFO0) then send 0x18F003F8. Until I reset the MCU, 0x18F003F8 is still received but on FIFO0 not FIFO1.
Any thoughts on how this might be occurring? I am using the STM32Cube_FW_F4_V1.18.0 Drivers.
Thanks,
Sean
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-02-06 11:50 PM
I think it will always load into FIFO1 first, if FIFO1 available.
on the TX side, the TxFIFO with the highest priority is sent first independently of which order it was loaded.
don't forget the ABOM bit has to be Set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-02-07 6:53 AM
ABOM bit is set.
Transmitting from the STM32F439 to my PCAN tool works flawlessly. My issue occurs when I send messages from my PCAN tool to the STM32F439, In my testing one message should always be received in FIFO0 and the other in FIFO1. The message going to FIFO1 does go to FIFO1 until the first time I send the other message to FIFO0. Then everything goes to FIFO0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-02-07 4:28 PM
I dont have an answer for you, is it a problem if one or the other FIFO is taking all the work ?
secondly, there were a few questions about the functionality of : BankNumber
Can someone give us some more insight into the BankNumber issue ?
my code:
sFilterConfig.FilterNumber = 0;
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK; sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT; sFilterConfig.FilterIdHigh = 0x400 << 5; //11-bit ID in top bits sFilterConfig.FilterIdLow = 0x0000; sFilterConfig.FilterMaskIdHigh = 0x600 << 5; // resolves as 0x0400 - 0x05FF sFilterConfig.FilterMaskIdLow = 0x0000; sFilterConfig.FilterFIFOAssignment = 0; sFilterConfig.FilterActivation = ENABLE; sFilterConfig.BankNumber = 0;sFilterConfig.FilterNumber = 1;
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK; sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT; sFilterConfig.FilterIdHigh = 0x600 << 5; //11-bit ID in top bits // command channel sFilterConfig.FilterIdLow = 0x0000; sFilterConfig.FilterMaskIdHigh = 0x700 << 5; // resolves as 0x0600 - 0x06FF sFilterConfig.FilterMaskIdLow = 0x0000; sFilterConfig.FilterFIFOAssignment = 1; sFilterConfig.FilterActivation = ENABLE; sFilterConfig.BankNumber = 1;this allows messages from 0x400 to 0x6FF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2018-02-08 10:05 AM
I updated my HAL Drivers to 1.7.3 which resolved my FIFO issue.
Sean
