-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[stm32] Fdcan driver #325
[stm32] Fdcan driver #325
Conversation
rleh
commented
Feb 10, 2020
- Fdcan driver
- Example for Nucleo-G474RE
- Test on real hardware
- Can message filtering
- Enable CAN-FD long frame support
- Adapt other can drivers
s.printf("id=%04lx,mask=%04lx", f.identifier, f.mask); | ||
} | ||
else { // if(f.mode == Filter::Mode::DualIdentifier) | ||
s.printf("id=%04lx,id2=%04lx", f.identifier, f.mask); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you convert this to << syntax? The whole printf is quite large and it is fully optional.
s.printf("id=%04lx,id2=%04lx", f.identifier, f.mask); | |
s << "id=" << modm::hex << uint32_t(f.identifier) << modm::ascii << ",id2=" << modm::hex << uint32_t(f.mask) << modm::ascii; |
I have been working on the FD CAN driver for the last couple of days. It is working on internal loopback on an stm32g474. I still don't have the hardware available to properly test normal operation mode with bitrate switching. Once I've done that I'll try to update it so it will work with modm's auto generation. The code for the driver is here: You can also have a look at how I decided to handle the can message. I know it has been up for discussion how to handle it. |
Tested the code with two MCP2562FD. I could not get bit rate switching to work. It made no difference at all. Though I was still able to run at 5 MHz. I also tested enabling transmission delays but that resulted in can frame errors. All in all FD can is working. I don't know when I'll have time to update the code to modm's auto generation because I'm a bit busy with work. |
Thanks for your contribution!
Don't worry. There is always someone, who can help out. I am planning to use an STM32G47* with CAN in a design at work at the end of the month. So, this someone could be me, but I don't know if I can find any hardware for testing the flexible datarate mode. |
Just a heads up that the driver is setup to run off PCLK clock. I don't know how you would detect which clock the user setup the CAN Interface for. |
The good thing is the driver doesn't need to know where the clock comes from, its frequency is enough. The clock mux configuration is not done within the CAN driver. It is handled by the user and the information is passed to the driver on initialization. When calling |
Parsing SystemClock does not help as you need to on the stm32g4 to modify the RCC_CCIPR register to select the source. Right now I just hardcoded the selection. Something similar to this has to be done for FD CAN. |
Not necessarily. It is a design choice whether the FD CAN driver should manage the clock mux or the user does during clock configuration. Both are possible. If you look at the modm I²C and Uart drivers, none of the them touch the clock muxes. The user configures the clocks and puts the right value into the |