2023-06-02 05:55 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 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.
2023-06-02 07:33 AM
If you want to use CAN2, you have to enable CAN1 clock even if it will be not used. CAN1 APB clock should be enabled since CAN1 instance is a master from peripheral integration point of view and it manages the filtering part.
Regarding the filtering management between CAN1 and CAN2, I invite you to have a look at this thread:
Hope it helps.
2023-06-02 07:35 AM
The filter bank is split in two halves (you define the split point), and CAN2 has to use the filters on it's half.
Typically split at 14 so 0..13 on CAN1 14..27 on CAN2
The F4 basically has 1.5x CAN hardware, CAN2 is dependent on CAN1 working.
Transmit should work, double check pin configurations, AF settings, routine of pins physically to the transceiver. If not your board, double check schematic, and options / solder-bridges.
2023-06-02 09:31 AM
Hi Tesla,
Thank you for your reply.
I have seen that link but it didn't help much. In fact, I have seen all possible links and finally asked question here.
Did anybody try to run only CAN2 ? I know CAN1 clock has to be enabled.
---------
"The F4 basically has 1.5x CAN hardware, CAN2 is dependent on CAN1 working."
-----
What do you mean by this ? You mean, to make CAN2 work CAN1 also has to be configured (Clock, GPIO, FIFO, Filters etc) or only CAN1 clock is enough? Although I tried it already and it didn't work. I didn't try both together because CAN1 pins are being used for other purpose.
I have checked all my HW pins, connections even checked waveforms on Rx and Tx Pin. I am sure there is no issue of HW connections.
I have tried almost all combination of filter configuration I could find on internet but it still didn't work.
Like,
CAN2
filterBank=0,14,15,20
SlaveBank=0,14,15
I guess there is a a bug in STM32 MCU because so many people have reported it nobody got successful answer. I am talking about CAN2 only.
Regards,
Parvez Akhtar
2023-06-02 10:13 AM
I've had this working on a F407 RedDragon board back in the day, CAN1 to/from CAN2, used SPL, so pre-HAL
Also had CAN working on our own F2 / F4 boards.
Been a while, HW works adequately, but not invested in spending engineering time reproving it.
I mean it's not two complete CANbx instantiations, CAN2 adds perhaps 1/2 the transistors of the CAN1, so like a siamese twin, but sharing some critical organs, or like Intel's Pentium was 1.5x 80486, it got super-scalar by having two execution units, and occasionally it would have instructions only one could execute to completion.
CAN2
filterBank=14,15,... filters within the slave bank
SlaveBank=14
Filter's deal with reception.
Transmit mailboxes, limited resource. If there not completing / clearing, check error / status reporting to understand why.
2023-06-05 04:52 AM
Dear Parvez Akhtar,
Did you try CAN in loopback mode to discard any HW issue? if yes, could you please put a minimal FW with CAN2? If not, try to start with CAN in loopback mode and try again!