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.

C language coding style

Status
Not open for further replies.

imranahmed

Advanced Member level 3
Joined
Dec 4, 2011
Messages
817
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
Karachi,Pakistan
Activity points
6,492
Which type of code should in the main body or outside main body anybody know?
 

Which type of code should in the main body or outside main body anybody know?
Before main loop initializations take place, together with one shot actions during reset time. After that comes the main loop, where tasks are repeated over and over again. If for example you have a program that measures analog port and drives a LED according to the measured ADC value, then you would have a pseudocode as follows:

Code:
void main (void)
{
  unsigned int anValue;
  MakeLedPinOutput();  //initialize LED port pin
  InitializeADC();  //Initialize analog port

  while(1)
  {
    anValue = MeasureAnalogPort();  //get analog value
    ControlLed(anValue);  //drive LED accordingly
  }
}


Hope this helps.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top