2024-04-12 03:27 AM
I have seen that it takes about 28 ticks to read registers, so I think my stm32h750 runs really at 17Mhz, it seems is not risk, so perhaps it exists another more fast stm32 micro that have more 17 MIPS
2024-04-12 03:29 AM
If you get unexpected results, look on your side first for errors!
2024-04-12 03:58 AM
Which optimizer setting you use ? (try -O2 or -Ofast , i use -O2 most time.)
+
How you measure this ?
2024-04-12 04:09 AM - last edited on 2024-04-29 05:55 AM by STTwo-32
Hello @JLope.11,
Welcome to the ST community! Can you share with us the code or more details about it?
Also, as AScha.3 said which optimizer do you use? It differs if you use Keil or IAR.
Thanks,
SMSAD.1
2024-04-12 04:29 AM - edited 2024-04-12 04:31 AM
Of course, I used this to read registers:
a0=HRTIM1->sTimerxRegs[HRTIM_TIMERINDEX_TIMER_A].CNTxR;
a1=HRTIM1->sTimerxRegs[HRTIM_TIMERINDEX_TIMER_A].CNTxR;
I was surprised to see a difference of 28-32 ticks between the readings. This was annoying!
I then tried reading the DWT->CYCCNT counter and got slightly better results.
I used stm32cubeide with default parameters
2024-04-12 04:42 AM - edited 2024-04-17 01:33 AM
Now I used this code and -O2 optimization for speed and see a lot of improvements, here is a better code:
a0=DWT->CYCCNT;
a1=DWT->CYCCNT;
i=GPIOC->IDR & GPIO_PIN_0;
a2=DWT->CYCCNT;
i=GPIOC->IDR & GPIO_PIN_0;
a3=DWT->CYCCNT;
i=GPIOC->IDR & GPIO_PIN_0;
a4=DWT->CYCCNT;
a5=DWT->CYCCNT;
printf("a0,1,2,3,4,5= %5lu %5lu %5lu %5lu %5lu %5lu ",a0,a1,a2,a3,a4,a5);
printf("d1,1,2,3,4= %4lu %4lu %4lu %4lu %4lu\r\n",a1-a0,a2-a1,a3-a2,a4-a3,a5-a4);
Now I see to read the counter is needed 10ticks always, and the gpio pin 34-42 tics,
Thanks a lot!
To set optimizations:
Right-click on your project in the Project Explorer window in properties, C/C++ Build->Settings,
in Setting windows, click MCU/GCC Compiler->Optimization: set -O2