cancel
Showing results for 
Search instead for 
Did you mean: 

Why my clock core of my stm32f is 10MHz?

RGira
Associate II

Hi, I try to speed up my core because I need speed. I have routine who start PWM and I need it to be done in 1,33 microsecond.

My problem here is my clock core speed is 10MHz, (according to keil uvision 5). And when I watch the assembly code, for single instruction "MOV" it takes 23 states to be done. So 23 * 100 nanoseconds for 1 instruction. It's to slow for what I want to do.

Did I miss something when I configure the clock tree ?

There's a picture of my configuration done with stm32cubeMx :

0690X000006C0Q1QAK.jpg

Thanks for your help

Reno

4 REPLIES 4

Sorry your presentation here is lacking.

What part are we talking about specifically.

What's the code doing?

Access over the APB going to take 4 cycles.

RMW going to take 8​

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

I need to do 3 PWMs who are phase shifted by 120 degree. Each frequency PWM is 250KHz. So i need 1,33 microseconds delay between PWM.

But I can't do my decision into 1,33 microseconds because the clock core seems too slow. A simple "if(counter == 1) takes a lot of times... (More then 1,33 microseconds)

As I see the picture of my clock tree didn't work.

RGira
Associate II

0690X000006C0PrQAK.jpg

There's a long way from a C statement such as "if (counter == 1)" to machine code, depending on many factors, of which the compiler optimization settings have probably the most dramatic effect. Then there's a long way from machine code to execution time, depending e.g. on what memory is code executed from, and if it's FLASH, what's its latency.

For precise timing, you want to use as much hardware as possible, and want to avoid software at all costs. In this case, you probably want to learn how to link timers.

If you are uncertain of your system clock, output it to a MCO pin and measure using oscilloscope or logic analyzer (LA).

JW