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.

Pls explain the usage of Infinite While/For loop in Firmware

Status
Not open for further replies.

senthilnathan.rajesh

Junior Member level 3
Joined
Apr 12, 2006
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,518
Could you please explain the significance of infinite while loop in the main function of any Firmware. (Example: Firmware for Blinking LEDs using 8051)

Is the loop required to continuously run the Firmware or May be is it for action of a Scheduler...?
 

Without an infinite loop the program will run amok as the processor executes non-programmed memory.
 

Re: Pls explain the usage of Infinite While/For loop in Firm

I've answered this question in another thread, but here goes:

When you reach the end of your code processing, the Instruction pointer will keep incrementing and executing code. Suppose I used 45k of 64k in the chip. When I hit the end of my code, I continue into the 45k - 64k range. I don't want this, because the information above 45k is unpredictable. I want to keep the properties known, so I sit the program in an infinite loop at the end of the program. You can also just have the program loop, but the point is you need to keep the properties of your program known so that it doesn't do anything unpredictable.
 
Re: Pls explain the usage of Infinite While/For loop in Firm

And there is another reason. Most of micocontrollers requires some intialization phase after reset. Usually, this initialization takes some time ( even hundreds of milliseconds) and is desirable to be performed only one time. If the infinite loop would not exist, when the program counter goes over 64K range it returns to address 0 and re-execute the initialization. It would be like a reset generated each time the program counter goes over the program memory range.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top