2018-09-10 04:42 PM
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 :
Thanks for your help
Reno
2018-09-10 05:00 PM
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
2018-09-10 05:06 PM
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.
2018-09-10 05:06 PM
2018-09-11 12:45 AM
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