Professional Documents
Culture Documents
#include
#include
#include
#include
#include
#include
#include
#include
#include
<stdio.h>
<stdlib.h>
"system.h"
<xc.h>
<libpic30.h>
"lcd.h"
"keypad.h"
"glcd.h"
"GraphicalLCD.h"
"Picture.h"
void InitADC(void);
int ReadADC(char Analogchannel);
int main(){
rewrite_register();
InitADC();
TRISB=0;
while(1)
{
LATB=ReadADC(0);
}
return 0;
}
void InitADC(void)
{
AD1PCFGL &=~(1<<0);
////
//ConfigPinsAsAnalog();
AD1CON1 = 0;
AD1CON1bits.AD12B = 1;
//
AD1CON1bits.FORM = 0;
//
AD1CON1bits.SSRC = 0;
//
sampling and starts converting.
AD1CON2bits.CSCNA = 0;
//
AD1CON2bits.VCFG = 0;
//
AD1CON3 = 0x1F02;
//
s >75ns
IFS0bits.AD1IF = 0;
//
IEC0bits.AD1IE = 0;
//
AD1CON1bits.ADON = 1;
//
}