C language coding style

Status
Not open for further replies.
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

Cookies are required to use this site. You must accept them to continue using the site. Learn more…