STM32H743VI FDCAN didn't works as classical CAN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-11 06:07 AM
Hello, I have some trouble with FDCAN.
Please let me know what is wrong with my settings.
1. Current problem
: My STM32H7 transmit only error.
(Logic Analyzer)
(PCAN View)
Same error signal repeat endless and if I connect PCAN, many other error and stuff error occur and can bus status become BUSHEAVY.
I check where does HAL_FDCAN_AddMessageToTxFifoQ() return HAL_ERROR.
First transmission, HAL_FDCAN_AddMessageToTxFifoQ() return HAL_OK(but in Logic analyzer and PCAN, it is just error) and in Second transmission, TXFQS is 0x00 20 00 00 and enter a if state under and return HAL_ERROR.
I think it is become there was no ACK from PCAN. Therefore Tx Que in STM32 will not reset.
Maybe PCAN can't give ACK to STM32 because STM32 didn't transmit hole CAN frame as you can see upper logic analyzer screenshot.
2. How I test CAN communication.
This is what I setup for debugging.
* I didn't attach 120 Ohm terminal resistor because length of CAN bus is short. (it is shorter than 50cm.)
3. Current setting.
3.1 Bit timming and HW settings
I am using 12MHz for CANbus from HSE(12MHz TCXO) and SN65HVD231Q-Q1 CAN transceiver.
I follow this settings. Under code is in main.c -> static void MX_FDCAN2_Init(void)
hfdcan2.Init.NominalPrescaler = 1;
hfdcan2.Init.NominalSyncJumpWidth = 3;
hfdcan2.Init.NominalTimeSeg1 = 20;
hfdcan2.Init.NominalTimeSeg2 = 3;
hfdcan2.Init.DataPrescaler = 1;
hfdcan2.Init.DataSyncJumpWidth = 3;
hfdcan2.Init.DataTimeSeg1 = 20;
hfdcan2.Init.DataTimeSeg2 = 3;
3.2 other settings (Under code is in main.c -> static void MX_FDCAN2_Init(void))
hfdcan2.Instance = FDCAN2;
hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
hfdcan2.Init.Mode = FDCAN_MODE_NORMAL;
hfdcan2.Init.AutoRetransmission = ENABLE;
hfdcan2.Init.TransmitPause = DISABLE;
hfdcan2.Init.ProtocolException = DISABLE;
hfdcan2.Init.MessageRAMOffset = 0;
hfdcan2.Init.StdFiltersNbr = 1;
hfdcan2.Init.ExtFiltersNbr = 1;
hfdcan2.Init.RxFifo0ElmtsNbr = 1;
hfdcan2.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan2.Init.RxFifo1ElmtsNbr = 0;
hfdcan2.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan2.Init.RxBuffersNbr = 0;
hfdcan2.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
hfdcan2.Init.TxEventsNbr = 0;
hfdcan2.Init.TxBuffersNbr = 0;
hfdcan2.Init.TxFifoQueueElmtsNbr = 1;
hfdcan2.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
hfdcan2.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
--------------------------------------------------------------------------------------------------------
I already check example on github and AN5348 document but I can't find why it didn't work. (actually, I don't know lot about memory system in STM32.)
I attach my main.c file and ioc file.
If you know how to use classic CAN. please help me.
Thank you!
Solved! Go to Solution.
- Labels:
-
CAN
-
FDCAN
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 05:34 AM
Hello,
CAN_H line is not changing in the screenshot you provide. Could you please check?
Also, I suggest to add 2x120 ohms on the line even the length is short (just for the test).
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 05:34 AM
Hello,
CAN_H line is not changing in the screenshot you provide. Could you please check?
Also, I suggest to add 2x120 ohms on the line even the length is short (just for the test).
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-12 05:44 AM - edited ‎2024-02-12 06:02 AM
Also could you please increase the system clock using PLL (for example @120MHz)and keep FDCAN clock source as HSE? (just for the test)
Could you also share your transceiver datasheet?
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-13 09:00 AM - edited ‎2024-02-13 09:09 AM
Hello,
I did some tests playing with system clock and FDCAN kernel clock and this is a table summarizing the results:
I don't recommend you configuration.
To be safe choose FDCAN kernel clock less or equal than Sys clk / 2
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-13 09:08 AM
Attached a project from which I got these results.
Details:
- Using H743 NUCLEO board
- FDCAN in Classical mode
- Loopback mode is used
- PLL1 used for system clock
- PLL2 as source for FDCAN ker clock
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-02-19 06:00 AM
Thank you so much.
I get some hint from your first suggestion(CAN H is not changing) and I found there was 330Ohm resistor between CAN transceiver and MCU. It increase RC constant of signal line. I delete this 330 Ohm resistor and add 120 Ohm termination resistor. These actions make CAN works!
I increase system clock to 75MHz too.
Thank you again!