www.pudn.com > hf44b0_TEST.rar > ADC.C
#include#include "..\inc\def.h" #include "..\inc\44b.h" #include "..\inc\44blib.h" #include "..\inc\tp.h" #define LOOP 1000 volatile unsigned char adcend=0; void __irq Adc_or_TsSep(void); void __irq Adc_or_TsSep(void) { int i; U32 Pt[6]; rI_ISPC=BIT_EINT4567; //clear pending_bit rEXTINPND=0xf; rADCCON=0x0<<2; // AIN0 for(i=0;i<5;i++) { rADCCON|=0x1; // Start X-position conversion while(rADCCON & 0x1); // Check if Enable_start is low while(!(rADCCON & 0x40)); // Check ECFLG Pt[i]=(0x3ff&rADCDAT); } Pt[5]=(Pt[0]+Pt[1]+Pt[2]+Pt[3]+Pt[4])/5; Uart_Printf("[AIN0] is %04d\n", Pt[5]); adcend=1; for(i=0;i