Main Menu
Home
AVR News
Atmel AVR
AVR Development Tools
Valuable Tools
WinAVR toolset
Makefile for WinAVR
AVR Virtual Simulators
Hardware for prototyping
GCC and AVR-GCC
Short introduction to C
AVR-GCC Tutorial
Example AVR Projects
AVR-GCC articles
WinAVR Site Map
Scienceprog FORUM
ScienceProg BLOG
Disclaimer
WinARM Tutorial
Latest comments
Measuring motor speed and...
Dear Administrator The code above...
More...

Programming AVR ADC module...
hi please send me example usart with...
More...

Measuring motor speed and...
main.c: In function...
More...

Running TX433 and RX433 RF...
(Hopefully this is not a re-post). I am...
More...

Running TX433 and RX433 RF...
I just bnought a pair of the RX/TX 433...
More...

Friendly sites

Related Items:

Recommended sites


Endless loops in embedded programs PDF Print E-mail
Written by Administrator   
Tuesday, 07 November 2006
Last Updated ( Tuesday, 07 November 2006 )

 

A series of instructions that are constantly repeated. Also called an "infinite loop," it can be caused by an error in the program or be intentional. For example, a screen demo on continuous replay just keeps repeating itself.

Probably you have noticed that many programs have similar structure like:

endless loop 

int main(void)
{
int i;
 while(1) //infinite loop or super-loop
  	{
	i++;
   	 }
 return 0;
}


Often in embedded program structure you may find endless loops: while(1) {}; Why they are used here and what does it give to embedded programs?

First of all endless loops are used here because there is no any operation system to return to/ So application keeps running until power is removed.

Why it is good to use endless loops:

  • Super-loops are simple to use, because it is easy to build, debug test and maintain;

  • Endless loops are hardware efficients as they require minimal hardware resources;

  • They are highly portable.

But there is other side of using super loops:

  • Super-loops doesn't guarantee accurate timings;

  • Endless loops operate at full microcontroller power and may not be necessary in all applications. They can have big impact on system power consumption.

To avoid unnecessary power consumption, it is good practice to use various sleep modes. All not needed functions should be disabled. Sometimes you may only need microcontroller to wake on some external event like external interrupt, or TWI (I2C) event.

You need to consider all these factors when designing battery driven projects.


Related Items:

   

Users' Comments  
 

Average user rating

 


Add your comment
Only registered users can comment an article. Please login or register.

No comment posted



mXcomment 1.0.6 © 2007-2008 - visualclinic.fr
License Creative Commons - Some rights reserved
< Prev

© 2008 WinAVR AVR-GCC Tutorial
Joomla! is Free Software released under the GNU/GPL License.