Skip to main content
Associate
Jan 20, 2025 3:05 PM UTC
Solved

stm32L496 error clock offset

Good morning community,

I am using the STM32L496QGI6 for a certain application using the uart to send and receive messages, in this case it always gives me symbols even with the baudrate correctly configured, I have checked the clock configuration and it is correct for 80Mhz but when checking by means of a 70ms pulse on any pin it tends to have a phase shift of almost 10%, the SYS has been configured with the TIM3, what is the cause of this phase shift, how can I correct it? I have tested the same configuration with an STM32L476 and everything works correctly.

 

CamiloRJ9_4-1737385379622.png

CamiloRJ9_0-1737385338471.png

This topic has been closed for replies.
CamiloRJ9Best answer
Associate
Jan 21, 2025 7:07 PM UTC

@AScha.3 , @Andrew Neil 

Thank you very much for the answers, they were very useful. I checked the configuration. A new project was initialized from scratch to see what was affecting it. I reconfigured the clock but with HSI and within the RCC configuration the HSI calibration parameter at 64 worked correctly. It was 16 before, but now I have some doubts about this value with respect to what is selected, how does it affect the offset? and how does it work internally?

CamiloRJ9_0-1737486449154.png

 

4 replies

Andrew Neil
Super User
Jan 20, 2025 3:34 PM UTC

You're running from internal RC oscillators - that's never a good thing with UART comms:

https://community.st.com/t5/stm32-mcus-products/stm32-internal-oscillator-drift-over-time/m-p/762198/highlight/true#M270687

 

Did you check the actual baud rate on the wire?

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
AScha.3
Super User
Jan 20, 2025 3:34 PM UTC

Hi,

you cannot use an RC oscillator (HSI) and expect exact timing.

Use HSE + crystal , then you get correct frequency.

Or to check: put out the clock on MCO and check with a DSO  - then you know,

is the hsi clock or your program the "problem".

If you feel a post has answered your question, please click on " Best Answer ".
CamiloRJ9AuthorBest answer
Associate
Jan 21, 2025 7:07 PM UTC

@AScha.3 , @Andrew Neil 

Thank you very much for the answers, they were very useful. I checked the configuration. A new project was initialized from scratch to see what was affecting it. I reconfigured the clock but with HSI and within the RCC configuration the HSI calibration parameter at 64 worked correctly. It was 16 before, but now I have some doubts about this value with respect to what is selected, how does it affect the offset? and how does it work internally?

CamiloRJ9_0-1737486449154.png

 

Andrew Neil
Super User
Jan 21, 2025 7:17 PM UTC

Why are you worrying about this "offset"?

For UART comms, it's just the frequency that matters.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.