problem with output RA2 and RA3


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mat janssen
    When I read the datasheet of the 16F88 then I see other configurations than you filled in at adcon0 and adcon1.
    You say:
    ADCON0 = %11100001 ' Configure and turn on A/D Module
    I read for this:
    do nothing with adcon0
    You say:
    ADCON1 = %00000010 ' Set PORTA analog and RIGHT justify result
    I read for this:
    adcon1 = %10000000 'only right justify and nothing about set port a.
    I read this
    ADCON0.0=1 ' A/D converter module is operating

  2. #2
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    The adcon0,0 is an internal bit to tell us what the condition is of the adc.
    You need it if your programm is made in assembler.
    All of this is solved for you in the picbasicpro compiler.

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    i change with this:

    Code:
        CMCON = 7                       ' PortA = digital I/O    
    	ANSEL = %00000011               ' Will set RA0-RA1 as analog and all others as digital 
        TRISA = %00000011  
        ADCON0 = %11000001	            ' Configure and turn on A/D Module
        ADCON1 = %00000000 	            ' Left justified. Six Least Significant bits of ADRESL are read as ‘0’
    and work but i want only the positive result and not the negative of command: if (value - P2) >= 1
    23 - 25 = -2 (P2=25)
    27 - 25 = 2 (P2=25)
    the pin PORTA.2 turn on , and for -2 and for 2 , but i want only for 2.
    How to make this;

  4. #4
    Join Date
    Oct 2003
    Location
    holland
    Posts
    251


    Did you find this post helpful? Yes | No

    Default

    Test if the first number is greater then the second number and then do the subtraction. If otherwise then do nothing.

  5. #5
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mat janssen
    Test if the first number is greater then the second number and then do the subtraction. If otherwise then do nothing.
    Thank you.
    I use this code:

    Code:
        If value >= P2 then
            If (value - P2) >= 1 then
                PORTB.1=1
                else
                PORTB.1=0
                endif
            endif

Similar Threads

  1. Pin won't stay high during Repeat...Until loop??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th August 2009, 23:57
  2. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  3. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 04:52
  4. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  5. This should be simple?
    By jderson in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 29th September 2008, 21:20

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