Can't get switch to work


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Apr 2007
    Posts
    7


    Did you find this post helpful? Yes | No

    Thumbs up That works

    Bruce:

    Thanks for your help. Those changes solved it. Which line was responsible for keeping it from working?

    CMCON = 7 ' all digital - comparators disabled

    OR

    The RETURN in the IF THEN block?

    Thanks again for your help!

    Jeff

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by JeffnDana View Post
    Bruce:

    Thanks for your help. Those changes solved it. Which line was responsible for keeping it from working?

    CMCON = 7 ' all digital - comparators disabled

    OR

    The RETURN in the IF THEN block?

    Thanks again for your help!

    Jeff
    That is why Skimask did not do a re-write for you, you did not learn or listen to him.

    Blocks of code, GOSUBS/RETURNS,etc and CMCON.

    Print you code and the code Bruce did, study side by side - line by line.

    Your first try was not far off for a first timer pun intended
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Hi Jeff,

    CMCON was the show stopper for the switch input, but GOSUB's without the
    RETURN (as already mentioned) was another problem.

    You might also want to include a conversion routine just after your GOSUB
    Read_1307 to convert before displaying the results.

    Something like this;

    Temp var byte ' for conversion routine

    Then just after GOSUB Read_1307 insert GOSUB Convert.

    Here's Convert:
    Code:
    Convert:
        IF hour >=$10 THEN
           Temp = (hour>>4)&$0F
           Temp = (temp*10)+(hour&$0F)
           hour=temp
        ENDIF
        IF minute >=$10 THEN
           Temp = (minute>>4)&$0F
           Temp = (temp*10)+(minute&$0F)
           minute=temp
        ENDIF
        IF second >=$10 THEN
           Temp = (second>>4)&$0F
           Temp = (temp*10)+(second&$0F)
           second=temp
        ENDIF
        RETURN
    I just happened to be working on a few routines for the SLED-C4, and figured
    I would give you a boost.

    And, yes, you should also get cozy with the 16F62xA datasheet so you'll
    know what each I/O-pin can do & what you'll need to write to certain
    registers to make things work right...;o}
    Regards,

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

Similar Threads

  1. PortA Doesn't Work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 11
    Last Post: - 8th September 2015, 18:41
  2. Newbie - 16F628A and switch latching
    By malc-c in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 19th May 2006, 02:35
  3. Why doesn't my code for 18f452 work on 18f252?
    By senojlr in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd December 2005, 02:42
  4. Switch Sequence
    By Tissy in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 13th February 2005, 20:36
  5. Pin RA4 doesn't work
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 0
    Last Post: - 15th July 2004, 12:03

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