As I was lying in bed this morning, a curious thought suddenly popped inside my head... (What do you mean, thinking about microcontrollers during your Sunday lie-in isn't normal?
)
Take a fresh-out-of-the-bag microcontroller - for sake of discussion, say an AVR - that has never been used before, and is blank/empty, with nothing programmed on it. You hook it up to power in an appropriate manner, and turn it on. What will it actually be
doing?
What I mean by that is, from an external viewpoint it may be sitting there doing nothing, but what's actually
executing on the CPU?
Would it simply depend on what the default contents of the flash memory is? Is the flash memory just pre-filled with null bytes? That would make sense for an AVR, as
0x0000 is the
NOP instruction. But then how would it keep looping so forever? Would it keep executing instructions until it reaches end of program memory, then wrap around to the beginning?
Or, is there some other behaviour? Perhaps some kind of special value pre-programmed in that tells the CPU to halt or sleep straight away?