Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature currently requires accessing the site using the built-in Safari browser.
That depends on the uC and how your "main" program was constructed. Most processors have a RESET line. As long as RESET is in the active state the processor does nothing except run the oscillator and place all registers in a defined state.
I believe the AVR oscillators run in RESET, and the internal RESET remains active for a predetermined interval after the external sources have gone inactive. This is accomplished by counting oscillator cycles.While the device is in reset, the oscillator won't run, and it won't set anything up - things only start happening once the oscillator is running. It would also be unusual for the processor to perform any 'setting up', the person writing the program normally has to do that.
I think even your precious PIC processors have defined reset states for many registers in the register file. I know of no processor that does not set some number of internal registers to known states on exit from RESET. I think you are just wrong on both points for some processors. You may be correct about the oscillator being stopped on some processors, but any processor that can take an external oscillator probably isn't one of them.During Reset, all I/O registers are set to their initial values, and the program starts execution
from the Reset Vector.
...
The I/O ports of the AVR are immediately reset to their initial state when a reset source goes
active. This does not require any clock source to be running.
After all reset sources have gone inactive, a delay counter is invoked, stretching the internal
reset. This allows the power to reach a stable level before normal operation starts. The time-out
period of the delay counter is defined by the user through the CKSEL fuses. The different selections
for the delay period are presented in “Clock Sources” on page 37.
I believe the AVR oscillators run in RESET, and the internal RESET remains active for a predetermined interval after the external sources have gone inactive. This is accomplished by counting oscillator cycles.
There are prescribed initial values for many of the special function registers. It is also true that some bits in some registers are undefined. From the ATmega128 datasheet.
https://www.electro-tech-online.com/custompdfs/2009/06/doc2467-1.pdf
I think even your precious PIC processors have defined reset states for many registers in the register file. I know of no processor that does not set some number of internal registers to known states on exit from RESET. I think you are just wrong on both points for some processors. You may be correct about the oscillator being stopped on some processors, but any processor that can take an external oscillator probably isn't one of them.
I find it hard to believe you wrote that. When a data sheet provides data on the state of a register at power up it can be trusted.While some registers 'may' power-up in a defined state, there's no code running to make that happen, and you certainly shouldn't trust what values might be there.
First I would like to say that I tried to stay out of this. Based on the posts in this thread none of us know enough about the internal working of the uC's to debate what is real. To make it worse, I would expect the documentation to tell what you will see, rather then how it is accomplished. It may even tell a few white lies in the name of simplification.
I find it hard to believe you wrote that. When a data sheet provides data on the state of a register at power up it can be trusted.
Well thank you all guys..
but where is the role of boot loader in the start-up of a microcontroller?
is it the "cstartup"??
I never said that the processor runs instructions during RESET, but the oscillator will beat up and down. From the 16F128A datasheet the only thing that shuts off the oscillator is SLEEP(see figure 14-1). The OP asked a reasonable question and we have a difference of opinion on the answer. If the answer is important it is easy enough to put a scope on the oscillator and see.
As a matter of policy I always code initialization routines to explicitly set registers to initial values that are appropriate to an application, even if it happens to be the same value as specified by the hardware RESET. It's cheap insurance.
I am in agreement, I read your original statement to be overly strong, and it is not.Surely you're not so naive as to believe datasheets are faultless?, don't assume anything - set it yourself. The number of errors in datasheets is legendary, and they don't even seem to bother correcting the errors in later editions.
We were taught to practice paranoid programming, aka belt and suspenders programming.