Moderator: Mats P
I have a weird issue with optimization. I'm writing drivers, so far one for an USART, and one for an SPI.
Final app will require high performance, so I'm regularly checking that everything works fine on O3.
Target MCU is STM32F401CC, I do not use the hal nor the standard peripheral library, only the registers definition and their flags. The code is c++ only.
The USART driver went fine, I can init, receive and transmit (using DMAs) without any problem on O0, O3, Os, etc.
But the SPI driver triggers an IBUSERR as soon as optimization is set above O0 (even on Og !). I did check the compiled code and the disassembly seems fine, loading registers with values and modifying them with BIC.w and stuff. If I reorder some lines of code, then the hard fault error triggers on a different line (but always in the SPI init function, or just after returning from it). Isn't IBUSERR precise ? It seems there can be a few instructions before it triggers.
I'll post the code tomorrow, but does anybody already faced this kind of issue ?
I already did check the classical errors like uninitialized variables, etc.
I forgot to update, but I did make it work, altough I don't know exactly why it was not working.
I was manually triggering the STM32 timer overflow so that the auto reload counter was updated (they are shadow registers), and this caused the problem, it seems if you enable an interrupt and trigger it in the next very few cycles, it does not correctly starts the ISR.
I delayed this trigger in a later stage of the init procedure and everything is working fine even on -O3.
Who is online
Users browsing this forum: No registered users and 1 guest