2019-05-08 01:55 AM
Hi All;
I found the problem with 1us. I use this function below
static void DelayMicroSeconds(uint32_t uSec)
{
uint32_t uSecVar = uSec;
uSecVar = uSecVar* ((SystemCoreClock/1000000)/3);
while(uSecVar--);
}
I will show result below
My evolution board for test.
In keil use this function at 30uS
In STM32CubeIDE use same function at 30uS
Anyone Who can help me about delay in microsecond?
Thank you,
Best regards.
Solved! Go to Solution.
2019-05-08 04:55 AM
Such tight loops for delays should always be 'calibrated' first before use. Then happily ignore any difference in compilers.
-- pa
2019-05-08 02:09 AM
Is the system clock set the same?
2019-05-08 02:22 AM
Hi @hansd56 ;
Yes. I set system clock at 84MHz. Now I can do it I must to set prescale is 7 for 84MHz/1M/7 = 12. I measure via oscilloscope.
Thank you,
Best regards.
2019-05-08 02:36 AM
Did you try different compiler optimization levels?
2019-05-08 03:21 AM
Hi @Knut_Knusper
I choose None (-O0) for optimization.
Thank you,
Best regards.
2019-05-08 03:31 AM
I've found the STM32CubeIDE compiler ignores many settings even on -o0.
My guess is Keil assigned a register and decremented that whilst STM32CubeIDE (can we have an agreed shorter name for this tool - "S32IDE" maybe ?) possibly does a load/store to memory every decrement which would probably accurately account for the wider time. Have a look at your .list file in the Debug folder to confirm if this is the case.
If so try using :
register volatile uint32_t uSecVar asm ("r4");
Don't use registers less than r4 or greater than r8 because the S32IDE compiler seems to over-protect them.
2019-05-08 04:55 AM
Such tight loops for delays should always be 'calibrated' first before use. Then happily ignore any difference in compilers.
-- pa
2019-05-08 06:16 PM
Hi @MikeDB
Thank you for your advice.
Thank you,
Best regards.
2019-05-08 06:16 PM
Hi @Pavel A.
Thank you for your advice.
Thank you,
Best regards.