cancel
Showing results for 
Search instead for 
Did you mean: 

HSE Crystal Oscillator and FDCAN on STM32C092: message is not being sent

Neiliow
Associate III

ST moderator edited the title to give more visibility on the issue/subject

Hello,

I have a board with an STM32C092KCU6 where the main clock is using the HSI48 internal oscillator but I also have an 8MHz crystal for the HSE oscillator to use for FDCAN for higher precision. When the HSE is clocking just the FDCAN module the CAN does not work.

I can get the CAN to work by using HSI48 as the FDCAN clock source. I can also get the CAN to work if I use HSE as the main clock (but it is too slow) or if I enable the clock output MCO2 with HSE as its source or also if I enable the RTC module and set HSE as its source.

So it seems that the HSE oscillator will only work if it is being used on FDCAN + one other place.

 

Osc for core
CAN clk
RTC clk
MCO2
CAN working?
HSI48
HSE
-
-
No
HSE
HSE
-
-
Yes
HSI48
INT
-
-
Yes
HSI48
HSE
HSE
-
Yes
HSI48
HSE
-
HSE
Yes
HSI48
HSE
-
HSI48
No

I first thought this was a gain margin or a drive problem but I calculated that Gm is 7.57 for the crystal I have used. Also, my colleague has tried this on a C092 Nucleo board and says he can see the same thing.

Any clues as to what the problem might be would be appreciated.

Many thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
mƎALLEm
ST Employee

Hello,

After doing the difference between both code sources, I noticed the following line was different:

Working:

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;

Not working: 

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

So it seems like CubeMx does generate the code related to HSE only if we enable something related to HSE example enabling MCO2 to output HSE or setting the system clock to HSE but it doesn't generate the code related to the HSE when only HSE was selected as source clock for the FDCAN.

I'm escalating this behavior to CubeMx team for analysis and for eventual fix. 

So from your side, in RCC configuration, replace:

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;

by:

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;

and it will work. For sure you need to replace these lines each time you generate the code.

Internal ticket number for follow-up: 217709 not accessible by the ST community members.

This post will be moved to CubeMx forum board as it seems to be a CubeMx issue.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

16 REPLIES 16
mƎALLEm
ST Employee

Hello @Neiliow ,

First, with CAN/CAN-FD it's not recommended to use any of the internal clock source HSI/HSI48 etc .. You should use an external precise clock source with HSE: crystal or crystal oscillator.

Second, please refer to this article as you could be in the same situation as what is described in this article: FAQ: Fixing STM32 FDCAN communication disruptions - APB bus, kernel, and time quanta clocks

The FDCAN requires that the CAN time quanta clock is always below the APB clock:

fdcan_tq_ck   <   fdcan_pclk

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Neiliow
Associate III

Hello mƎALLEm,

Thank you for your reply and for the link to that article. I need to read it in more detail, however -

1. I was just using HSI48 clock to test the CAN. In my design I want to use HSE as the FDCAN clock and that is what is not working.

2. I think my clock configuration shown below meets the requirements since my APB clock is 48MHz and the FDCAN clock is 8MHz.

Screenshot 2025-09-11 164450.pngKind regards,

Neil

 

First, start by using one of the loopback modes. Do you face the same issue with that config? this is important to know from which way to go..

Second, what is the sample point set and what is the mode used: classical/CAN-FD? what are the BS1, BS2 values?

Third, you didn't tell what do you mean by "is not working"! wrong frames? communication doesn't start at all? other?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Neiliow
Associate III

Hi,

Thanks for your suggetions.

The FDCAN is configured as -

Neiliow_0-1757662783501.png

which are the same settings for Tq, Tseg1, Tseg2, etc as we have used in other designs, although they are based on F042 / F072 devices. This is the first design where I have used the C092.

I am testing it by trying to periodically transmit a message out to the CAN bus. By 'not working' I mean the message is not being sent. If I then change the clock settings to either use the HSI48 clock (and change the prescaler to 6 to keep Tq=125ns) or if I enable MCO2 sourced from from HSE or if I enable the RTC and use HSE as its clock source then the message is sent. This is reliable and works every time.

I have ordered some different crystals to see if that could be the problem but one of my colleagues has a C092 Nucleo board and he says he can see the same thing happening so I'm not sure that is the cause.

Hello,

As I said previously, please try with External Loopback mode and see what happens on Tx. Unfortunately, I don't have STM32C092 chip to test.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

OK, I tried it in external loopack mode and basically the same -

CAN clock from HSE : nothing on CANTx / CANRx

CAN clock from HSI : continuous CAN data packets on CANTx / CANRx

CAN clock from HSE + MCO2 from HSE : continuous CAN data packets on CANTx / CANRx

 

Hello,

Thank you for the feedback. Is that possible to attach two minimal projects in loopback mode (working/not working) that reproduces the behavior? Hopefully I can find a NUCLEO-C092RC to test it.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

No problem. I have attached the project (as it is for our target hardware). To toggle between working / not working Enable / Disable the "Master Clock Output 2" in the RCC configuration, using HSE as the MCO2 clock source.

We are not currently using the MCO2 pin (PB2) so it isn't a problem to use it for this test.

It should send a CAN message every 200ms.

Hope that gives you something you can work with.

Sorry something I didn't catch in your issue. When you say:

"To toggle between working / not working Enable / Disable the "Master Clock Output 2" in the RCC configuration, using HSE as the MCO2 clock source."

Do you mean the issue is related to the enable/disable of the Master Clock Output 2? 

So if you enable MCO2 it's working, otherwise not?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.