‎2020-12-14 05:20 AM
Hi, I want to use both CAN1 and CAN2 for my application with 500kbps and 125kbps speeds respectively. I have initialized both of them as per my requirements using HAL. Where in Tx is implemented in polling and Rx in interrupts. CAN1 Tx and Rx working perfect. Coming to CAN2 Tx is working and Rx is not working. Interrupt itself is not firing up for CAN2 Rx (HAL_CAN_RxFifo0MsgPendingCallback is not being called). I've read in datasheet that some SRAM sharing process is happening between 2 CANs. I'm unable to comprehend that. Is that an issue?
I'm attaching the code also. Please check and help!
Solved! Go to Solution.
‎2020-12-14 09:41 AM
Clear local/auto variable for predictable behaviour
CAN_FilterTypeDef sFilterConfig= {0};
For CAN2
sFilterConfig.FilterBank = 0; // NO!! 14 thru 27 for CAN2 FILTERS
..
sFilterConfig.SlaveStartFilterBank = 14; // THIS IS THE RESOURCE SPLIT POINT, 28 BANKS, 14 FOR CAN1 14 FOR CAN2 IN 50/50 SPLIT OPTION
‎2020-12-14 05:58 AM
There are about 1.5X full CAN controllers, they share a FIFO, and the split is configurable. The CAN2 needs to use the second half of the FIFO, above the split point you have configured.
‎2020-12-14 09:20 AM
Hi @Community member​
I didn't get what you said. There are 2 Rx FIFOs.
Should I use RXFIFO0 for CAN1 and RXFIFO1 for CAN2?
(or)
CAN_RDL0R and CAN_RDH0R must be managed for both CAN1 and CAN2?
Can you tell me where have I configured (above the) split point in my code?
‎2020-12-14 09:41 AM
Clear local/auto variable for predictable behaviour
CAN_FilterTypeDef sFilterConfig= {0};
For CAN2
sFilterConfig.FilterBank = 0; // NO!! 14 thru 27 for CAN2 FILTERS
..
sFilterConfig.SlaveStartFilterBank = 14; // THIS IS THE RESOURCE SPLIT POINT, 28 BANKS, 14 FOR CAN1 14 FOR CAN2 IN 50/50 SPLIT OPTION
‎2020-12-14 09:42 AM
One more update - I tried configuring FIFO0 for CAN1 and FIFO1 for CAN2.
Result - Now CAN2 is receiving data perfectly and CAN1 doesn't even call callback function.
What's wrong?
‎2020-12-14 10:00 AM
Hey @Community member​
As suggested, cleared local variables.
CAN 1:
sFilterConfig.FilterBank = 0;
:
sFilterConfig.SlaveStartFilterBank = 14;
CAN2:
sFilterConfig.FilterBank = 14;
:
sFilterConfig.SlaveStartFilterBank = 14;
I guess above config is correct because it is working now.
Also I'm using separate Rx FIFOs right now for dual CANs. Need to check if it works with a single FIFO. That's not my priority at this moment.
BTW, thanks for saving my time. I knew that you'd be the one to answer my question . ST community is filled with your valuable answers :smiling_face_with_halo: .
Cheers :beer_mug:
‎2020-12-14 10:16 AM
Yeah, I feel like I'm stuck here forever..
‎2020-12-14 10:16 AM
Probably need unique filter bank for each
‎2020-12-14 10:22 PM
Its okay as long as you enjoy what you do and get :heavy_dollar_sign::heavy_dollar_sign::heavy_dollar_sign: (assuming).
‎2023-06-02 06:24 AM
I wanted to us CAN2 interface in my project. I started with example application ("CAN_Networking"). This example application works very well with CAN1 but when CAN2 is configured in this application it doesn't work at all. No transmission and no reception. I tried recommended solution from here too but it still didn't work.
I searched online for similar problem and I got many issues related to same. But I tried all the solution and nothing worked. Sharing links below
https://stackoverflow.com/questions/36311263/stm32f1xx-can2-receive-interrupt-not-being-called
https://stackoverflow.com/questions/65290032/using-both-can1-can2-both-in-stm32f446-properly
https://stackoverflow.com/questions/27315649/stm32f429-is-not-receiving-the-can-message
I am sure it has something to do with filter setting and driver being provided by STM team. But it seems they didn't test their example programs with CAN2.
Please help me if anybody have solution of this problem.