Hello,
I have code for 10 bit ADC which is normally working with PIC18F2455 and I want to use this code for 12 bit ADC with PIC18F2523.
I changed Define ADC_BITS 10 to ADC_BITS 12, but results are sill 10 Bits.
I using 20 MHz external oscillator.
How to configure this code for 12 bit ADC with PIC18F2523 ?
Thank you
Here is my code:
Define LOADER_USED 1
DEFINE OSC 48
' Define LCD registers and bits
Define LCD_DREG PORTB
Define LCD_DBIT 4
Define LCD_RSREG PORTC
Define LCD_RSBIT 7
Define LCD_EREG PORTC
Define LCD_EBIT 6
DEFINE LCD_BITS 4 ' 4-bit data bus
DEFINE LCD_LINES 2 ' LCD - 2 lines
' Define ADCIN parameters
Define ADC_BITS 12 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
adval var word ' Create adval to store result
TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %00001010 ' Set PORTA analog...
ADCON2 = %10000000 ' ...and right justify result
Pause 500 ' Wait .5 second
loop: ADCIN 0, adval ' Read channel 0 to adval
Lcdout $fe, 1 ' Clear LCD
Lcdout "Value: ", DEC adval ' Display the decimal value
Pause 100 ' Wait .1 second
Goto loop ' Do it forever
End
Bookmarks