Problem in ADC - PIC18F1220

SSIDAO

New Member
Hello,

I'm using a PIC18F1220 to control a lead-acid battery charger circuit.
I'm having troubles in the A/D conversion in the simulations with Proteus.

The follow message appears:
''ADC conversion clock period (8e-06) is below recommended 1.6us."

I'm using 2 ADC channels (10-bits) (to read temperature and battery voltage)

Temperature function:

int read_temp (void)
{
restart_WDT();
set_adc_channel (sAN0);
delay_ms(30);
Trd = read_adc();
delay_ms(30);
restart_WDT();

return (Trd);
}

Voltage reading function:


float read_voltage (void)
{
restart_WDT();
set_adc_channel (sAN1);
delay_ms(30);
restart_WDT();
Vrd = read_adc();
delay_ms(30);
V = ((Vrd*150)/1023);
restart_WDT ();

return (V);
}

What I need to do to solve this problem?

Thx.
 
Can you show where you configure the A/D module of the PIC in your code?
In particular, you should have configured the A/D clock in the ADCON2 register. Please refer to Table 17-1 in the datasheet to choose it correctly.
 
How I can configure this ADCON2 register programming in C?

The A/D configurations are:

restart_WDT();
setup_oscillator (OSC_2MHZ|OSC_NORMAL);
SETUP_ADC(ADC_CLOCK_DIV_32 | ADC_TAD_MUL_20);
SETUP_ADC_PORTS(ALL_ANALOG| VSS_VDD); //Actually i use only the pins
restart_WDT(); //A0 and A1 as analog inputs

I'm using standard_io.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…