This is absolutely killing my program!
Environment: M328P, AS7 with reasonably up-to-date avr-gcc (can't figure out where to find the installed version number) on Win10. Programmer is Atmel Dragon, if it matters, though it should not.
I have the usual "endless loop" in main(). There is an initialization section at the top of main, followed by the loop. When I single step from the end of the initialization section to where it lands in the endless loop, it jumps directly to an FatFs f_write() function where NONE of the arguments are properly initialized and the file system is NOT even open! This is the firmware equivalent to murder! Not even time to shout "Et tu Brutus?"
When I look at the disassembled code, the first thing it does after the end if the initialization is to call that f_write() function. There is NOTHING in the c code that requests that as a task for initialization! It just seems to do it, as if it thinks that might be funny to try.
THEN, it jumps to a block toward the end of the run loop where it prepares for sleep. At that point, some of the wake-up events are NOT ready because earlier parts of the run-loop, on which those depend, have not been executed. There goes the second stab!
Is there any way to suggest/direct/force the transition from initialization to the run-block at a better/more desirable/preferred jump target point? I suppose that I could put the body of that run-loop into a function and make that function call as the only element of the loop. Would that force a particular order? If I were to do that, there would be copious references to global variables that are external to the function, and lint (which I am not yet using) would probably love that.