analog inputs on 16F716


Closed Thread
Results 1 to 4 of 4
  1. #1
    schwinn_rider's Avatar
    schwinn_rider Guest

    Default analog inputs on 16F716

    Hi all,

    I'm trying to do a row-column setup of analog inputs with the 16F716, and send the analog values out through serial. My problem is pretty basic though-I'm just not sure how to set up analog input on this chip. WHen I compile I get the following errors:

    Symbol not previously defined (ADRESH)
    Symbol not previously defined (ADRESL)

    Here's the code:
    <CODE>
    ' set up constants to use in the code
    numRows con 4 ' number of rows
    numCols con 4 ' number of columns
    colOffset con 0 ' first column pin in column port
    ' set up variables:
    rows var byte ' the row counter
    cols var byte ' the column counter

    ' set up ADC parameters
    DEFINE ADC_BITS 10
    DEFINE ADC_CLOCK 3
    DEFINE ADC_SAMPLEUS 20

    ' set up ADC variables
    ADCVar var word

    ' set pins RA0-RA3 as input :
    TRISA = %00001111
    ' set pins RB0-RB3 as output (and RB6 as output for serial comm.):
    TRISB = %10110000
    ' set adcon?

    ADCON0 = %10000010 ' set porta analog and right justify result
    Pause 500

    main:

    'send out a message showing that this is the beginning of the loop
    Serout2 portb.6, 16468, ["end of loop", 13, 10]

    ' loop over the columns, turning on one at a time
    for cols = 0 to 3
    ' set this column high to check the switches in it:
    PORTB = 1 << cols
    ' loop over the rows, reading one switch at a time:
    for rows = 0 to 3

    ' read the analog value in
    adcin 0, ADCVar

    ' send the value out through serial
    Serout2 portb.6, 16468, [DEC ADCVar, 13, 10]
    next
    'set this column low to prep for the next column loop:
    PORTB = 0
    next


    goto main
    </CODE>

    Any clues on how to set up the analog input stuff? I'm pretty new at this, but i have done similar things on other chips.

    Thanks,

    Matt

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    You can only instruct PBP to use "10-bit" A/D resolution on a target with a 10-bit A/D module.

    Try changing to 8-bit, and see how it works...;o}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Your trying to configure the chip for a 10-bit converter when it only has an 8-bit.

  4. #4
    schwinn_rider's Avatar
    schwinn_rider Guest


    Did you find this post helpful? Yes | No

    Default

    that did it. thanks!

Similar Threads

  1. Erratic analog inputs .
    By timseven in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 10th October 2009, 22:34
  2. pic18f analog comparator problem
    By david.silaghi in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 6th May 2009, 09:38
  3. Multiple analog inputs ?
    By rngd in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 25th February 2008, 15:13
  4. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  5. Many Analog Inputs
    By Ioannis in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 10th July 2006, 08:15

Members who have read this thread : 0

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