Part Number: F29H85X-SOM-EVM
Hello,
I am currently working on the F29H85x platform and I observed an unexpected behavior related to the DEVICE_DELAY_US() macro when optimizations are enabled.
I started from the official example: led_ex1_blinky. The code runs as expected with lower optimization levels, but when enabling -O1 -flto the LED blinking behavior becomes incorrect (timing is inconsistent or completely wrong).
The issue seems to come from the implementation of the delay:
void SysCtl_delay(uint32_t count)
{
__asm volatile(" MV A0, D0 \n" \
" DECB A0, #1, 0x0 \n");
}
However, if I move SysCtl_delay() into a separate .c file (instead of being inlined), the behavior becomes correct again, even with LTO optimizations enabled.
It looks like the problem is related to the Link Time Optimization (LTO)
Does this mean that LTO should be disabled for all DriverLib files when building an application?
While LTO appears to be very effective in improving performance, I am concerned about its impact on legacy code when migrating from F28x to F29x.
Thanks