16F688 problem


Closed Thread
Results 1 to 8 of 8

Thread: 16F688 problem

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    I think Joe nailed it, but check the datasheet for the value to disable comparators. I think
    it should be CMCON0 = 7 on the 16F688.

    Pins configured as analog inputs will be read as 0 when used for digital I/O.

    The HIGH / LOW commands use BSF and BCF read-modify-write assembly language
    instructions. This causes the whole port to be read, the port pin to be modified, then the
    whole port is written back to each time it lands on a HIGH LOW instruction.

    Example:

    high LineLockOut ' reads whole port, sets C.1, writes whole port back.
    high ClutchOut ' reads whole port, (C.1 is read back as 0), sets C.0, writes it back.
    high Aux1Out ' reads whole port, (C.0 is read back as 0), sets C.2, writes it back.

    If pins are set to analog inputs, then it reads each pin value back as 0, then writes it back
    as a 0 on the next BSF operation, so you end up with only Aux1Out being set once it runs
    through all three lines of code above.

    The same scenario can happen with read-modify-write. Even if the pins are not configured
    as analog inputs.

    If it blazes through these three lines of code at a high-speed, and there's a little bit of
    external capacitance on these pins, the next read-modify-write operation after changing
    the first output pin - may read the pin before it has had time to change, so it writes back
    the wrong value to a previous pin when it changes the next pin.

    When that happens, you can fix it by inserting a short pause between each instruction that
    sets or clears pins, or you can just write to the whole port at once instead of setting or
    clearing individual bits one at a time.
    <h1>RATS !</h1> Misread the chart CMCON0=0 comparators off ANALOG, CMCON0 = 7 comparators off DIGITAL !
    THANK YOU BRUCE !
    Last edited by Archangel; - 9th May 2009 at 18:55.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Misread the chart CMCON0=0 comparators off ANALOG, CMCON0 = 7 comparators off DIGITAL !
    Which is where ALLDIGITAL.pbp comes in really handy.
    http://www.picbasic.co.uk/forum/showthread.php?t=11100
    <br>
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks guys, I haven't had a chance to test yet but thanks.

  4. #4


    Did you find this post helpful? Yes | No

    Default

    I got the following errors with the AllDigital.pbp, any ideas?

    opcode expected instead of a variable
    undefined symbol 'showdigitalresult'
    undefined symbol 'showdigitalresult'

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Thank you Tobias.

    I made some changes after testing with the PM assembler. Should have tested that assembler again. Sorry bout that.

    Removing the variable opcode and the indent makes it work with PM again.
    Code:
    ;----[Module defaults]------------------------------------------------------
      #define SHOWDIGITALDEFAULT  0
      ifdef SHOWDIGITAL
    SHOWDIGITALRESULT = SHOWDIGITAL
      else
    SHOWDIGITALRESULT = SHOWDIGITALDEFAULT
      endif
      ifndef PM_USED
        ifndef ADLISTALL
          nolist
        endif
      endif
    I'll update the main file.

    Thanks again,
    DT

Similar Threads

  1. 16F688 counter problem
    By jderson in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th February 2008, 04:06
  2. Problem with PWM using 16F688
    By electrocomp in forum General
    Replies: 9
    Last Post: - 1st December 2007, 14:14
  3. A/D problem ON 16F688
    By Christopher4187 in forum General
    Replies: 2
    Last Post: - 19th October 2005, 22:13
  4. 16F688 problem
    By Christopher4187 in forum General
    Replies: 0
    Last Post: - 16th October 2005, 02:00
  5. Problem with 16F688 and Hserout
    By DWV in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 19th March 2005, 05:37

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