Thanks Ioannis and George,
Here is the corected and 100% working code example using ADCIN:
Code:
' PIC 16F690 Fuses
@ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_HS_OSC &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
'-------------------------------------------------------------------------------
' Registers 76543210
OPTION_REG = %10000000 'OPTION register
ANSEL = %00000000 'Select analog inputs Channels 0 to 7
ANSELH = %00000000 'Select analog inputs Channels 8 to 11
WPUA = %00000000 'Select weak pull-ups
WPUB = %00000000 'Select weak pull-ups
ADCON0 = %00000000 'AD Module
ADCON1 = %00000000 'AD control register
CM1CON0 = %00000000 'Comparator1 Module
CM2CON0 = %00000000 'Comparator2 Module
INTCON = %00000000 'INTerrupts CONtrol
TRISA = %00000000 'Select Input/Output (0 to 5)
PORTA = %00000000 'Set High/Low (0 to 5)
TRISB = %00000000 'Select Input/Output (4 to 7)
PORTB = %00000000 'Set High/Low (4 to 7)
TRISC = %00000000 'Select Input/Output (0 to 7)
PORTC = %00000000 'Set High/Low (0 to 7)
'-------------------------------------------------------------------------------
' Defines
DEFINE OSC 8
DEFINE LCD_DREG PORTC 'LCD data port
DEFINE LCD_DBIT 4 'LCD data starting PORT.bit (0 or 4)
DEFINE LCD_RSREG PORTC 'LCD register select port
DEFINE LCD_RSBIT 3 'LCD register select bit
DEFINE LCD_EREG PORTC 'LCD enable port
DEFINE LCD_EBIT 2 'LCD enable bit
DEFINE LCD_BITS 4 'LCD bus size 4 or 8
DEFINE ADC_BITS 10 'Number of bits in ADCIN result
'-------------------------------------------------------------------------------
' Init display
' ELECTRONIC ASSEMBLY DOGM081 LCD display Mandatory settings
' See datasheet for circuitry changes by 5V or 3,3V operation
PAUSE 1000 'Time to settle Vdd (THIS IS CRUCIAL FOR THIS DISPLAY!!!)
LCDOUT $FE, $29 'Function Set: 4 bits bus mode
LCDOUT $FE, $1C 'Bias set
LCDOUT $FE, $52 'Power control + Contrast (HiByte)(for 5V=$52 or 3,3V=55)
LCDOUT $FE, $69 'Follower control (5V=$69/3,3V=6D)
LCDOUT $FE, $78 'Contrast (LowByte)
'-------------------------------------------------------------------------------
' Variables
Bat_Value var word 'holds ADC value
Bat_Value = 0
'-------------------------------------------------------------------------------
' Start program
MAIN:
ADCON0 = %10000000 ' Here we drive the 0,6 volts to the ADC
VRCON = %00010000 ' Enable the VP6 reference
ADCIN 13, Bat_Value ' Select the VP6 channel's address ADCON0 = %xx1101xx
Bat_Value.HIGHBYTE = ADRESH : Bat_Value.LOWBYTE = ADRESL
LCDOUT $FE,2,DEC4 Bat_Value
PAUSE 1000
GOTO MAIN
END
Bookmarks