A/D Converter andA/D Converter and ComparatorComparator PIC 12F675PIC 12F675 Zdeněk Matěj 72963@mail.muni.cz A/D ConverterA/D Converter Conversion of an analog input signal to a 10Conversion of an analog input signal to a 10-- bit binary representation of that signalbit binary representation of that signal PIC 12F675 has 4 ADC (multiplexed)PIC 12F675 has 4 ADC (multiplexed) Generates interrupt (ADIF)Generates interrupt (ADIF) A/D block diagramA/D block diagram A/DA/D -- ANSELANSEL A/DA/D ­­ ADCON0ADCON0 A/DA/D ­­ output registersoutput registers A/DA/D ­­ example (without INT)example (without INT) //A/D//A/D initinit //ADCS2 ADCS1 ADCS0 ANS3 ANS2 ANS1 ANS0//ADCS2 ADCS1 ADCS0 ANS3 ANS2 ANS1 ANS0 ANSEL=0b1100001;ANSEL=0b1100001; //ADFM VCFG//ADFM VCFG ---- ---- CHS1 CHS0CHS1 CHS0 GO/DONE ADONGO/DONE ADON ADCON0=0b00000000;ADCON0=0b00000000; ADON=1; //ENABLE A/DADON=1; //ENABLE A/D convertorconvertor GODONE=1;GODONE=1; //start//start if (GODONE==0) {data=ADRESH;}if (GODONE==0) {data=ADRESH;} //data//data rdyrdy ComparatorComparator The PIC12F629/675 devices have one analogThe PIC12F629/675 devices have one analog comparatorcomparator Compare two analog valuesCompare two analog values On GP0 and GP1 are inputs to theOn GP0 and GP1 are inputs to the comparatorcomparator GP2 can be the comparator outputGP2 can be the comparator output Generates interrupt (CMIF)Generates interrupt (CMIF) ComparatorComparator -- CMCONCMCON ComparatorComparator ­­ operation modesoperation modes ComparatorComparator ­­ voltage referencevoltage reference The voltage reference can output 32 distinctThe voltage reference can output 32 distinct voltage levelsvoltage levels ComparatorComparator ­­ voltage referencevoltage reference ComparatorComparator -- exampleexample //init//init //// -- COUTCOUT -- CINV CIS CM2 CM1 CM0CINV CIS CM2 CM1 CM0 CMCON=0;CMCON=0; output=COUT;output=COUT; ReferencesReferences Source:Source: http://ww1.http://ww1.microchipmicrochip..comcom//downloadsdownloads/en//en/devdeviicedoccedoc/41190c./41190c.pdfpdf