I have a problem with recent version of gcc (10.x and above (11.x) if I compile with -Ofast and lto (gcc10) and even with -Os and lto (gcc11)
Don't really understand the problem, but the loop exits early, so chSysPolledDelay does not wait for the desired time.
If I a add dummy variable setting in the loop like :
Code: Select all
static volatile uint32_t dummyCnt=0U;
void chSysPolledDelayX(rtcnt_t cycles) {
rtcnt_t start = chSysGetRealtimeCounterX();
rtcnt_t end = start + cycles;
while (chSysIsCounterWithinX(chSysGetRealtimeCounterX(), start, end)) {
dummyCnt++;
}
}
the problem is resolved (of course that is not a fix, just a clue to search for proper way of fixing)
I also tried to see the assembly output with compiler explorer, but with my limited arm ISA knowledge, i don't spot any obvious compiler issue in the generated code :
assembly output
edit 1/
can see the effect in the timing of driving pins in a big project, but not able to reproduce the problem with a small example, keep searching ...
Alexandre