Go Down

Topic: How do I use AVR studio? (Read 3 times) previous topic - next topic

dcb


westfw

An Arduino sketch IS exactly a C++ program, except that it already includes (as part of the runtime environment) a function main() defined as:
Code: [Select]
int main(void)
{
     init();     // Part of arduino environment
     setup();  // Provided by you in the sketch
     for (;;)
       loop();  // Provided by you in the sketch
     return 0;
}

This isn't really any different that the code that a more traditional compiler environment executes in your program before it calls main() (usually something like _start(), contained in the crt0 library);  it's just a convenience for embedded applications  (for instance, you no longer have to explain to people what should happen when the program is "done"; it's clear that it just keeps calling loop() forever.)

Syvwlch

#22
Oct 07, 2008, 12:45 pm Last Edit: Oct 07, 2008, 12:45 pm by Syvwlch Reason: 1
westfw, thanks for sharing that little nugget, lots of things just made all kindza sense for me.

techx, if you're not finding what you need here, the polite thing to do is thank people for their time trying to help and try something else.
----------
Mathieu

techx

#23
Oct 07, 2008, 03:40 pm Last Edit: Oct 07, 2008, 03:45 pm by brianfast Reason: 1
goodbye arduino forum

Digger450

Goodbye techx, you are welcome!

Go Up