ADC Sampling Requirements

Setting up the AtoD Sampling Look up the following in the device datasheet: Tad = ADC Clock period ADC Clock Period Sample Time Conversion Time (value not needed to setup but this tells you how long it will take to convert) ADCS – ADC Conversion Clock Select bits ADC_CONV_CLK_#Tcy  This value sets Tad: Tpb (Peripheral bus speed) […]

Read More

AD1PCFG or ANSEL

Most PIC32's use AD1PCFG to define pins as analog or digital, but not all.  If your device doesn't have that register: Look in the datasheet for ANSELx registers (ANSELA, ANSELB, etc) Check your OpenADC10() call if you use it isnt' based on ENABLE_AN0_ANA etc for the final AD1CSSL register parameter as these will be wrong for ANSELA etc based devices  

Read More

PIC32 AtoD

Automatically Read A Single Analog Input CloseADC10();// ensure the ADC is off before setting the configuration OpenADC10( (ADC_MODULE_ON | ADC_IDLE_STOP | ADC_FORMAT_INTG16 | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON | ADC_SAMP_ON), //AD1CON1 register (ADC_VREF_AVDD_AVSS | ADC_SCAN_OFF | ADC_ALT_INPUT_OFF | ADC_SAMPLES_PER_INT_10), //AD1CON2 register (ADC_SAMPLE_TIME_4 | ADC_CONV_CLK_PB | ADC_CONV_CLK_3Tcy), //AD1CON3 register (SET THE SAMPLE TIME ETC) (ENABLE_AN0_ANA), //AD1PCFG register (SET […]

Read More