cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G474: CAN-Bus clock and timing setup

Hello,

regarding the STM32G474 I have some questions regarding the CAN Controller:

1)    The CAN-Controller has an input called “fdcan_clk�?, is this connected to APB1-peripheral-clocks?

2)    How does the CCU work to generate the fdcan_tq_ck, how should it be set up?

I found very little information about it, what would be a recommendation for a 500kBit/s CAN2.0B setup.

I assume the calibration-feature is most likely be used in the CAN-FD Mode, I may use that in the future. If someone has more details how set up, I would really be interested as well.

Many thanks for helping in advance.

Best Regards, Seppel

P.S. I also found different diagrams( RM0440 Rev 6 vs. AN5348 - Rev 1), not sure why that is the case. I also did not find where the registers are described in detail.

0693W00000GXU7bQAH.png0693W00000GXU7WQAX.png

4 REPLIES 4
Nick van IJzendoorn
Associate III

It's recommended to get the sample point between 75% and 87.5% so TSEG1 must be longer than TSEG2.

I mostly use an external tool to calculate the best configuration. For example: http://www.bittiming.can-wiki.info/

0693W00000GXYX9QAP.pngSo the nominal prescaler can be set to 20, with nominal TSEG1 to 13 and nominal TSEG2 to 2.

The data prescaler and TSEG's are not used when you only want to use CAN2.0 frames.

Another good tool is https://play.google.com/store/apps/details?id=com.peaksystem.BitRateCalculator&hl=en&gl=US but you will have to set the clock source to PLLQ for example and make sure it's output is 80MHz.

Hello,

in the meantime I found an example from ST: https://github.com/STMicroelectronics/STM32CubeG4/blob/master/Projects/STM32G474E-EVAL/Examples/FDCAN/FDCAN_Classic_Frame_Networking/Src/main.c

I'll give it a try and keep everyone updated.

Thanks a lot, Best Regards, Seppel

Javier1
Principal

I use a different chip with a different CANbus peripheral and im using CUBEMX ,but maybe this helps:

For the clock source i go to the ref manual (of my stm32f105xx) and find out which peripheral bus is my canbus atacched to (APB1)

0693W00000GXYxlQAH.pngIn cubemx, i setup the clock of the APB1 to the speed i want (max possible)0693W00000GXYyFQAX.png 

Inside CANBUS parameter settings i modify Time quantas to match the sample points i want (@Nick van IJzendoorn​ explained this)

0693W00000GXYwtQAH.pngCubeMX helps me by calculating the time quanta and total canbus speed i would get with the current parameters.

we dont need to firmware by ourselves, lets talk

There's another nice tool for STM32G4

https://phryniszak.github.io/stm32g-fdcan/

gaston