Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Programming

Status
Not open for further replies.
Just strted programming

Hi i just want to ask if this code is correct ? its for setting up three ADCs

Code:
	volatile unsigned int ADC_VALUE;

	/* Selecting ADC channel */
  ADCON0 = (ADC_Channel << 3) + 1;	 /* Enable ADC, Fosc/2 */			

	ADIE	  =	0;			 	/* Masking the interrupt */
  ADIF 	  = 0;					 /* Resetting the ADC interupt bit */						
	ADRESL	=	0; 			 /* Resetting the ADRES value register */
	ADRESH	=	0; 						 

  ADGO = 1;				 	 	/* Staring the ADC process */					
  while(!ADIF) continue;			   /* Wait for conversion complete */ 			

	ADC_VALUE	=	 ADRESL;                   /* Getting MSB of CCP1 */
	ADC_VALUE	+= (ADRESH << 8);		/* Getting LSB of CCP1 */

  return (ADC_VALUE);     /* Return the value of the ADC process */
} 

void main()
 
And I dont know exactly what the header file is, but is it a "setup" som that the compiler knows what code the different assembly code "stands for"?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top