-
Notifications
You must be signed in to change notification settings - Fork 23
Support CAN FD for STM32 targets #478
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
Conversation
enable MSIPLL auto calibration for L5,U5 serieses adjusted PLL1Q clock for H5, H7 series to enable CAN FD a data rate of 5 MBit/s
…TM32U5 improve the speed of recovery from stop mode
From my point of view nice work! |
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.
Thanks so much for working on this! Really awesome to have this new feature in Mbed. Looked through the code and, while I'm not a CAN expert, I did my best to give a review. Nothing too major, just some doc stuff and cleanups. Once you work through those, I am excited to merge this!
One more question. Will be possible to use both version in one application? For example create classic CAN for FDCAN1 and CANFD for FDCAN2.
|
Yes, it is possible to use both versions in one application. |
removed the unused parameter 'cc' from can_write and canfd_write reverted changes in TARGET_STM/sleep.c
…/get_canfd_data_prescaler functions
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.
Almost there, just a few more comments!
…ncy() with the existing functions minor fixes on documentation
…_init_freq_direct, can_frequency functions
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.
Nice work on this!
@wdx04 don't forget to create an issue about taking too long to wake up from deep sleep! |
Summary of changes
Added CAN FD support with a data rate up to 8Mbit/s on STM32 L5, G0, G4, H5, H7 and U5 families.
Unified the system_clock.c on STM32U5, as all STM32U5 devices normally work at 160MHz.
Fixed an issue where STM32U5 took too long to restore from deep sleep.
I measured the latency to transmit 64 bytes of data between two CAN FD instances on the same board, with external MCP2562FD PHY modules. The latency of various arbitration+data frequencies are measured on each board.
Impact of changes
Migration actions required
No source-level changes are required to existing CAN applications.
Documentation
The CAN FD interface reuses the existing CAN class with a few changes:
A new struct, CANFD_Message is used to holder CAN FD messages with payload size up to 64 bytes:
To support CAN FD on new targets, it is required to implemented these functions:
Pull request type
Test results
Currently there are no existing CAN-related greentea tests, so I tested with a minimal CAN FD test application.
For devices with two or more CAN FD instanes, CAN1 is used to send 64 bytes of data to CAN2(CAN3 on STM32G474) on the same device, then the received data is verified for correctness. For devices with only one CAN FD instance(L5 and U5), two boards are used for the test, where one board acts as sender and another board acts as receiver.
To test if the unified system_clock.c is working properly, I also run greentea tests on NUCLEO-U545RE-Q. There is one failed test: mbed-hal-common-tickers. More precisely, ticker_disable_test and ticker_overflow_test are failed. I found ticker_disable_test is added recently and ticker_overflow_test has been modified recently. If I revert the test code to a previous version, the mbed-hal-common-tickers is passable. Maybe the new/modified tests are too strict for some targets.
greentea-nucleo-u545re-q.txt
can-fd-test.zip