some modifications:
Code:
MAIN:
FOR J = 0 to 3 'Count 4 channels
'???<-->Shouldn't I set the ADCON0 as %11000001 to use the internal OSC, I want to use the internal OSC
'ADCON0=%10000001 'Set A/D Fosc/32,[4MHz],Channel-0 = on <----???? For External clock?
'ADCON0= 65 + (J*8) 'Set A/D Fosc/8, and Set a/d = on (This is actually ADCON0=%01000001
'65 = 1000001 channel 0,(GP0/AN0)
'73 = 1001001 channel 1,(GP1/AN1)
'81 = 1010001 channel 2,(GP2/AN2)
'89 = 1011001 channel 3,(GP4/AN3)
'".....if you're using the internal ADC RC oscillator, you need to set the ADCON0 bits ADCS1, ADCS0 to 11.
'Using the internal ADC clock is only desirable when running the PIC at low clock frequencies to conserve
'power. If you're using a 4MHz ceramic resonator, crystal or other clock source, you'll need to set these
' bits to either 01, or 10."--Rentron
'ADCON0= 129 + (J*8) 'Set A/D Fosc/32 Use internal 4MHz clock(8 usec to acquire data), and Set a/d = on
'129 = %10000001
ADCON0= 193 + (J*8) 'Use internal 4MHz clock(2-6usec to acquire data), and Set a/d = on
'193 = %11000001
'ADCON0=%11000001 'Use the internal clock
'Do I need to do this every time a channel is read ????
'Any alternate ???
' %11xxxxxx <---This means ADCS1(bit7)=1 and ADCS0(bit6)=1; see table by Rentron/data sheet
' %xxxxxxx1 <---This means ADON (bit0) = 1 ie. turn the A/D on
pauseus 10 'Wait for 10 u Sec for channel setup <---??? is the time OK?
Bookmarks