Support CAN FD for STM32 targets #478
Open
+643
−900
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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