Without putting too fine a point on it, it most definitely is doing a lot of work behind the scenes! Happy to discuss further – drop me a private message if you want more information.
However, it is doing this to make life easy for beginners in the use of microcontrollers, so that they can concentrate on getting hardware working without worrying about setting up the compiler and such like. Even just the compilation of a sketch hides an awful lot from you. I documented it at Tutorial for creating multi cpp file arduino project - #36 by normandunbar some time ago.
Other things that the Arduino does for you, at least on an Arduino Uno, are:
- Enables global interrupts.
- Creates a
main()
function which callssetup()
once, then loops around, callingloop()
. Bothsetup()
andloop()
are the ones in your sketch, obviously! - Configures the three timers in 8 bit mode, with a divide by 64 prescaler, and with PWM enabled on both channels to give 6 pins with PWM available. Timer 0 uses Fast Hardware PWM while Timers 1 and 2 use Phase Correct PWM. PWM being the
analogWrite()
function in your code. - Configures timer 0’s overflow interrupt to count up the time that has passed since power on/reset. This is “surfaced” in the
micros()
andmillis()
functions. - Disables the USART so that pins D0 and D1 can be used for GPIO purposes. This will be disabled when
Serial.begin()
is called to initialise the USART for Serial output. - The ADC is configured with a divide by 128 prescaler, enabled and powered on regardless of whether the sketch uses it or not. The
analogRead()
function in your code uses the ADC. - The Arduino boards are fused to set the BOD – brown out detector – to a voltage that is far too low for a 16MHz clock speed!
If it wasn’t for the stuff that the Arduino and its language hide from you, you, the developer, would have a lot more work to do even to get an LED blinking every second!
HTH
Cheers,
Norm.