Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

why while(1) is used after end of every programme??

Status
Not open for further replies.

harshan_behra

Newbie level 4
Joined
Dec 8, 2014
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
39
sir,
most of the embedded system programmers while they write code,at the end of the code they write while(1).what is the need of it?? how it effect for bootloaders??
 

With a while(1) you keep the program in an infinite loop (since the while condition is constant and will always be met) thus keeping the program alive while listening to external interrupts for example. In complex programs, most of the code isn't handled in a large main loop but in separate event handlers triggered by internal (brown out, timers) or external interrupts.
 

Without it the program would reach the end and terminate. In 'non-embedded' systems it would return to the operating system (Linux, Windows etc.) but as most embedded programs have no OS to return to, they have to re-enter their own program loop.

Usually you will find a matching 'do' statement near the beginning of the program loop, the while(1) is always true so it force the 'do' to run again.

Brian.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top