I have a headache.....INPUT anyone?


Closed Thread
Results 1 to 3 of 3
  1. #1

    Default I have a headache.....INPUT anyone?

    Could someone please enlighten me as to why this doesn't work on a PIC16F688?

    DEFINE OSC 4
    led1 var porta.2
    led2 var portc.2


    onoff var word
    sig var word
    p0 var word
    trisa.2 = 0
    trisc.2 = 0
    trisc.3 = 1
    trisa.0 = 1
    ADCON0 = 1


    main:
    onoff = portc.3
    If onoff = 1 then <----Hangup is here
    high led1
    ADCIN 0,p0
    sig = p0*4
    pause(sig)
    high led2
    pause(sig)
    low led2
    else
    low led1
    low led2
    endif
    goto main

    If I write it unconditional, it works beautifully. As soon as I try to tell it "only if C.3 is high" nothin...
    If I tell it "only if C.3 = 0"... works fine.
    I've also tried
    if (PORTC.3 = 1) THEN

    and

    if PORTC.3 = 1 THEN

    and

    onoff = PORTC.3
    if onoff = 1 then

    and
    if (onoff = 1) then

    According to everything I have found online, any of these should work. I'm apparently missing something.....

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default Re: I have a headache.....INPUT anyone?

    Hi,
    PortC.3 is also AN7 and the pins comes up in analog mode by default, to use the pin as a digital onput you need to enable the digital circuitry.
    See the ANSEL register and also the CMCON register even though it's not related to PortC.7 specifically.

    /Henrik.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: I have a headache.....INPUT anyone?

    Thanks so much! added ANSEL = 0 and works like a charm!

Similar Threads

  1. Have a headache - need some suggestions with code logic
    By Scampy in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 20th October 2013, 15:45
  2. Need some input
    By dhouston in forum Off Topic
    Replies: 0
    Last Post: - 7th March 2012, 12:23
  3. Mplab headache lol
    By Mus.me in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th December 2009, 00:58
  4. Real time clock... what a headache!
    By Eng4444 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 8th June 2006, 21:56
  5. DS1820 headache
    By Calco in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 12th August 2004, 00:28

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