cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with 1us clock signal generation from Timer in STM32G474 EV Board

Tung Nguyen (晉松)
Associate II

Hi Everyone. My EV Board use 24 MHz HSE but I used PLL to get with 170 MHz, I also set this frequency for the clock of timer module. I could get 2us periodic signal normal from timer setting however I cannot get 1us periodic signal normally (you can check the prescaler and ARR setting in picture). Is there any MCU limitation or what could be the problem? Thanks a lot for help!

***1us signal generation


_legacyfs_online_stmicro_images_0693W00000bl4r1QAA.png***2us signal generation


_legacyfs_online_stmicro_images_0693W00000bl4rBQAQ.png

6 REPLIES 6

Are you trying to toggle a pin in the timer's interrupt? That may not work simply because of interrupt routine's duration.

JW

Hi JW. Thank you for your reply. My purpose is to create 1us ISR, currently I do the GPIO toggle for the checking corectness of ISR duration purpose only. As your hyper link, look like the ISR take long time to finish itself, and no way to get the correct 1us for timer ISR, right?

That of course depends on what code runs in that ISR.

Cube adds unnecessary layers.

Compiler optimization setting also matters.

JW

Interrupts at 1 MHz are generally not viable, and no other work will get done.

Use the TIM HW modes to toggle a pin associated with a TIMx_CHx directly, or use a PWM Output mode with 50/50 duty.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Yes. Thank you for your reply. Actually, my target is to create 1us ISR for implement a state machine flow-chart with some if-else loop and also GPIO on and off in-side. The toggle GPIO in the waveforms showed above just the checking signals that I generated to make sure I got 1us or not!

Thank you for your reply with some nice keywords!