ADCIN and DT´s ALLDIGITAL


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187

    Default ADCIN and DT´s ALLDIGITAL

    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

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: ADCIN and DT´s ALLDIGITAL

    I never bother with setting up registers for analog inputs. The ADCIN command does it for you.

Similar Threads

  1. How to set ports to digital (ALLDIGITAL.PBP)
    By RayL113 in forum FAQ - Frequently Asked Questions
    Replies: 2
    Last Post: - 30th November 2013, 02:59
  2. Replies: 2
    Last Post: - 24th July 2013, 18:34
  3. Can´t get DT´s interrupts working
    By Mugelpower in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th April 2010, 14:11
  4. Can't seem to add AllDigital to the include files
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th November 2009, 04:21
  5. Adcin, can't get it right
    By atwoz in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 4th January 2008, 20:38

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts