Why would a project fail to run with no optimmisation and work with all the others?
There is a thread somewhere around which gives some explanation for this. If I remember it right, to make it simple: it is because the GCC was not meant for Harvard architecture mcus.
But either search for that thread or wait until some GCC guru comes in here.
Sometimes optimization is needed because code is not tested in all corner cases. Sections with critical timing might fail when compiled with no optimization.
You should compile your application with the optimization level you assume you will be shipping with, or else you might trip into bugs after releasing.
I typically compile with -Os if size is most important, or -O2 if speed is more important.
For in-system debugging (with JTAG) I have used -O0. Is that wrong? So far I haven't seen any anomalies in debugging mode, but indeed have had problems with the non-optimized or slightly optimized (-O1) code when uploaded to the board.
Interesting, I isolated the problem. Back to my trouble with declaring a naked ISR... Oh Lord
© 2020 Microchip Technology Inc.