stm32: Add support for FDCAN on the STM32N6.#19316
Conversation
|
Code size report: |
Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
Signed-off-by: Kwabena W. Agyeman <kwagyeman@live.com>
000161f to
2b33e15
Compare
dpgeorge
left a comment
There was a problem hiding this comment.
Thanks for the PR.
It doesn't build for me, I had to make the following change:
--- a/ports/stm32/Makefile
+++ b/ports/stm32/Makefile
@@ -421,7 +421,7 @@ endif
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),f0 f4 f7))
HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_, hal_can.c)
-else ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),g0 g4 h7))
+else ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),g0 g4 h7 n6))
HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/stm32$(MCU_SERIES)xx_, hal_fdcan.c)
else ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),l4))
HAL_SRC_C += $(addprefix $(STM32LIB_HAL_BASE)/Src/Legacy/stm32$(MCU_SERIES)xx_, hal_can.c)Also, something is wrong with loopback mode, and filtering. The tests/ports/stm32/pyb_can.py test should pass and run on OPENMV_N6 with this change, but it does not:
- it takes a long time to run, it seems to hit a timeout on send/recv
- the filtering part of the test doesn't work, it doesn't ever receive anything
Do you want me to look into that?
| // #define MICROPY_HW_CAN3_NAME "FDCAN3" | ||
| // #define MICROPY_HW_CAN3_TX (pyb_pin_CAN3_TXFD) | ||
| // #define MICROPY_HW_CAN3_RX (pyb_pin_CAN3_RXFD) | ||
| #define MICROPY_HW_CAN_IS_RESERVED(id) ((id != PYB_CAN_1) && (id != PYB_CAN_3)) |
There was a problem hiding this comment.
Can this be (id == PYB_CAN_2) to simplify it?
But, also, can this line just be removed because CAN2 isn't enabled. Reserved is when the peripheral is configured but used internally and not for user use.
There was a problem hiding this comment.
Yes, please change as required.
| UART4_RX,PA11 | ||
| UART4_TX,PA12 | ||
| CAN1_RXFD,PA11 | ||
| CAN1_TXFD,PA12 |
There was a problem hiding this comment.
How about calling these CAN1_RX and CAN1_TX to match the new alt-func names?
There was a problem hiding this comment.
I don't have an opinion on it other than making it compile.
|
Note: to run |
|
@dpgeorge - Can you take over this PR and fix it? I was just trying to get it working for a customer. I don't know how to properly test it. |
Yes! |
|
Investigating the failures here, one thing it needed was I'm still working on it... |
Adds support for CAN on the STM32N6 and enables it on the OpenMV N6.
Tested transmit and receive at 500Kb/s, and both are working.