Hello


The PBP manual says this about ADCIN
Before ADCIN can be used, the appropriate TRIS register must be set to
make the desired pins inputs. The ADCON, ANCON and/or ANSEL
registers must also be set to assign the desired pins to analog inputs
I want a value between 0-255 depending on the voltage (0-5V) on RA2 and was trying to set the registers without success and then I just tested the code below with Darrel Taylors ALLDIGITAL included and no additional register configurations and it works?

But I wonder why it works without setting the registers, and should I set them even if the code works and why?

Maybe a dumb question but I want to know
The PIC is an 16F886.

Code:
DEFINE OSC 4
include "ALLDIGITAL.pbp" ; Darrel Taylors ALLDIGITAL

DEFINE SHOWDIGITAL 1
;----[16F886 Hardware Configuration]--------------------------------------------
ASM
cfg1 = _INTRC_OSC_NOCLKOUT   ; INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
cfg1&= _WDT_OFF              ; WDT disabled and can be enabled by SWDTEN bit of the WDTCON register
cfg1&= _PWRTE_ON             ; PWRT enabled
cfg1&= _MCLRE_OFF            ; RE3/MCLR pin function is digital input, MCLR internally tied to VDD
cfg1&= _CP_OFF               ; Program memory code protection is disabled
cfg1&= _CPD_OFF              ; Data memory code protection is disabled
cfg1&= _BOR_ON               ; BOR enabled
cfg1&= _IESO_OFF             ; Internal/External Switchover mode is disabled
cfg1&= _FCMEN_ON             ; Fail-Safe Clock Monitor is enabled
cfg1&= _LVP_OFF              ; RB3 pin has digital I/O, HV on MCLR must be used for programming
cfg1&= _DEBUG_OFF            ; In-Circuit Debugger disabled, RB6/ICSPCLK and RB7/ICSPDAT are general purpose I/O pins
  __CONFIG _CONFIG1, cfg1

cfg2 = _BOR21V               ; Brown-out Reset set to 2.1V
cfg2&= _WRT_OFF              ; Write protection off
  __CONFIG _CONFIG2, cfg2

ENDASM
;===LCD Defines for EasyPIC5====================================================
DEFINE LCD_DREG PORTB     ; Set LCD Data port
DEFINE LCD_DBIT 0         ; Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB    ; Set LCD Register Select port
DEFINE LCD_RSBIT 4        ; Set LCD Register Select bit
DEFINE LCD_EREG PORTB     ; Set LCD Enable port
DEFINE LCD_EBIT 5         ; Set LCD Enable bit
DEFINE LCD_BITS 4         ; Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2        ; Set number of lines on LCD
'DEFINE LCD_COMMANDUS 1500 ; Set command delay time in us
'DEFINE LCD_DATAUS 44      ; Set data delay time in us
;-------------------------------------------------------------------------------

Level var byte
   
Main:

ADCIN 2, Level
LCDOUT $FE,1
LCDOUT $FE,1, "Level:", #Level
pause 200


goto main