Skip to main content
Neiliow
Associate II
September 11, 2025
Solved

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

  • September 11, 2025
  • 5 replies
  • 1392 views

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.

Best answer by mƎALLEm

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.

5 replies

mƎALLEm
Technical Moderator
September 11, 2025

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
NeiliowAuthor
Associate II
September 11, 2025

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

 

mƎALLEm
Technical Moderator
September 11, 2025

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
NeiliowAuthor
Associate II
September 12, 2025

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.

mƎALLEm
Technical Moderator
September 12, 2025

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."
Neiliow
NeiliowAuthor
Associate II
September 12, 2025

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

 

mƎALLEm
Technical Moderator
September 16, 2025

Hello,

Looking at your attached project, I see the FDCAN is not set to the Loopback mode but in Normal mode.

So I need a working project in Loopback mode where I can see the transmitted frame on PB1 with MCO2 enabled and no message transmitted when MCO2 is disabled. Please test the project before to attach it.

Thank you for your understanding.

"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
NeiliowAuthor
Associate II
September 17, 2025

OK, attached are 2 projects to run on a C092 Nucleo board which I have verified as showing the problem. The CAN data is present on "cantest_nucleo_HSE_MCO2" but not present on "cantest_nucleo_HSE".

Note it is on PD0 and PD1 on the Nucleo board, not PB0/1 as you said.

Thanks.

mƎALLEm
Technical Moderator
September 17, 2025

Thank you & well received.

I've reproduced the behavior. Need time to investigate it. I will keep you informed as soon as we find the 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."
mƎALLEm
mƎALLEmBest answer
Technical Moderator
September 17, 2025

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."
Neiliow
NeiliowAuthor
Associate II
September 17, 2025

Excellent detective work! Thanks for that. I'll do what you suggested until there is a fix in place.

Thanks again.