Skip to main content
Associate II
December 3, 2023
Solved

CAN working on when using internal clock source but not externale clock source?

  • December 3, 2023
  • 5 replies
  • 5111 views

Hi there,

When setting up my CAN bus using the cube mx generator tool, I found that switching from using an external clock source for my CAN peripheral to the intrenal one (HSI48) to be exact my CAN comms began to work.

Im not sure as to why this is possible as I though th extenal crystal were more accurate than the internal ones?

Any help shedding light on the situation would be greatly appreciated!

This topic has been closed for replies.
Best answer by Tesla DeLorean

So why are you setting in the Cube Clock Tree Diagram to 32 MHz?? The HSE source from the ST-LINK/V2-1 MCO pin is 8 MHz

Make sure HSE_VALUE in the stm32xyz_hal_conf.h also reflects the clock source.

5 replies

Tesla DeLorean
Guru
December 3, 2023

Not details on the clock itself or the board..

Is this a NUCLEO board, fed via ST-LINK 8 MHz MCO source,or something else.

Crystal source should be more stable and on-frequency. Can you put it on a frequency meter and measure? How much off-frequency?

What settings on bus, prescaler, SJW, BS0, BS1, etc.

Is the CAN source device on-frequency?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Oli98Author
Associate II
December 4, 2023

My Apologies!

Heres my CAN configuration settings:

Oli98_0-1701700809812.png

Heres my clock settings:

Oli98_1-1701700849263.png

Any help would be gretaly appreciated as I thought the extrenal clocks should be much more accurate however I can only get my CAN to work using the internal clock sources.

 

Karl Yamashita
Principal
December 4, 2023

You're not showing the external clock settings

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
Oli98Author
Associate II
December 4, 2023

Hey Karl,

Is this what you mean?

Oli98_0-1701718658671.png

also fro reference my oscillator pins:

RCC_OSC_IN: PF0

RCC_OSC_OUT: PF1

 

Thanks!

Tinnagit
Senior II
December 5, 2023

you should set clock to be HSE which it's 32MHz and it's difference from HSI 48MHz so You should adjust HSE by PLL to be 48MHz and use it as main clock.

It's should work fine.

Oli98Author
Associate II
December 5, 2023

Oli98_1-1701772552407.png

I tested like this and it still didnt work?

Tinnagit
Senior II
December 5, 2023

the other stuff is that you had soldering the external crystal already?

There is no High speed crystal on that board.

LCE
Principal II
December 5, 2023

@Oli98 grab a scope and check what's actually connected as HSE source.
On the Nucleos there is usually NOT a crystal, but the MCO from the ST-Link MCU.

If you soldered a crystal on to the Nucleo, then make sure that all the jumpers / solder bridges are set o removed correctly.

And as someone else already said, activate the MCO so that you cab check its internal clock.

Oli98Author
Associate II
December 5, 2023

Hi guys thankyou for the help, @Tesla DeLorean you was right! I assumed the deafult configuration for the nucleo board would be set to match the on board crystal which was 8MHz (the default value was 32MHz). changing the input frequency for HSE as per the diagram below:

Oli98_0-1701800483925.png

my CAN comms began to work, thankyou very much for the help guys, Im still learning about all this embedded stuff so I appreciate the time!

Thanks,

Oliver