PDA

View Full Version : Struggling with a P18f2550



chrisshortys
- 6th November 2011, 14:35
Hi all, I have been struggling since converting from a 16f876A chip over to the 18f2550.

My problems start as soon as i go to program with PICKIT2 i get the error: "Warning: Some configuration words not in hex file".
I have googled this and came back to an ansrew using older software and i dont think there has been a post since PB3?

Secondly even after programming though this and ignoring the error i can not get the ADCIN to operate. I believe i have enabelled this correctly for using pins 0,1 and 2:

DEFINE ADC_BITS 8 'SETS NUMBER OF BITS IN RESULTS
DEFINE ADC_CLOCK 3 'SET CLOCK SOURCE
DEFINE ADC_SAMPLUS 50 'SET SAMPLING TIME IN US


ADCON0 = %00000001
ADCON1 = %00001100 'SETS THE ANALOGUE/DIGITAL INPUTS TO BANK A
ADCON2 = %10111110 'right justified, AD=20AD, A/D clock=fosc/64


Am i missing something obvious here?

Thanks Chris

mackrackit
- 7th November 2011, 07:58
"Warning: Some configuration words not in hex file".
Is just a warning, not an error. This is telling you that there are more things that can be configured. Not a problem to get this warning.

You have things set for 10 bit
ADCON2 = 111110 'right justified
but you are also calling for 8 bit
DEFINE ADC_BITS 8
Decide on one.

To read Channel 0, "PORTA.0", 8 bit, all you need is


DEFINE ADC_BITS 8
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
ADCON1 = %00001110 'Sets PORTA.0 to analog
Then when you want to read the pin

ADCIN 0, MY_VAR