Hi,
I have code that uses an interrupt routine. My while loop in the main() function heavily interacts with results from the interrupt routine, so I know I have to use volatile for a fairly large number of variables where either my interrupt routine or my code within the while loop of main() change variable contents that the other part depends on.
The execution time of the code is too slow if I turn optimization off but I know that it works if I reduce the interrupt period low enough so I can debug my code.
When using optimization, however, my code hangs in the reset handler (startup file startup_samv71q21b.c that is executed before main()). I have no idea how to find the culprit for the hangs.
What is the right approach to find out what's going on? Right now I have the situation that -O2 and -Os work, but -O3 does not. I say "right now" because sometimes even -O2 doesn't work. I've also had the situation where -O3 worked but -Os gave me better execution time.
I am using Atmel Studio version 7.0.2389 and the native gcc compiler. I have also the option to use later gcc compiler versions provided by ARM.
The µController is a ATSAMV71Q21B.