PBP migration from 16F88 to 16F1827


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Sonofagun! It works. Thanks!

    What did we just do?

    And why was PORTB.1 working but not the others?
    Last edited by RussMartin; - 25th February 2010 at 22:46.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by RussMartin View Post
    Sonofagun! It works. Thanks!

    What did we just do?

    And why was PORTB.1 working but not the others?
    . . . and what is the "real" difference between LATB & PortB ?
    I am sensing a RMW issue . . . Thanks Darrel, in advance.
    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.

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


    Did you find this post helpful? Yes | No

    Default

    It's the old R-M-W issue (Read-Modify-Write).

    PIC's can't write to individual Pins in a PORT. It's not possible for the hardware to just set a pin high or low directly.
    It has to Read the entire PORT, Modify the bit it wants to change, then Write the value back to the Entire PORT.
    When it Reads the PORT, it actually reads the state of the Pins, not the state it was told to be in last.

    In your code ...
    Code:
    MAIN:
        OLO=1 : PAUSE 1000 : OLO=0
        OLM=1 : PAUSE 1000 : OLM=0
        OMD=1 : PAUSE 1000 : OMD=0
        OMH=1 : PAUSE 1000 : OMH=0
        OHI=1 : PAUSE 1000 : OHI=0
    GOTO MAIN
    The OLM=1 statement is executed immediately(125nS) after the OLO=0 statement.
    If the voltage on the OLO pin has not reached the level required to register a 0, then it reads OLO as 1 and writes that back to the PORT, ignoring that fact that you just told it to be 0.
    Capacitance on the Pin will increase the amount of time it takes to reach the requested state.
    Solderless breadboards can add quite a bit. LED's add some too.

    Just like the 18F's, the 16F1's have LATx (DATA LATCH) registers.
    If you use PORTB.0, it does the RMW on the PORT, then writes it to the LATB register which controls the pins state.

    If you write directly to LATB.0, it doesn't read the port first.
    It still does a read-modify-write, but what it reads is the LATB value (last requested state), not the state of the Pins.

    DO NOT! use HIGH, LOW, TOGGLE, or any other PBP commands like SERIN/OUT, PULSIN/OUT etc. with LATx.x as a Pin.
    It will cause big problems.

    But writing to the LATx bits directly with a 1 or 0 can eliminate the dreaded R-M-W problem.

    hth,
    DT

  4. #4
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Then:

    The reason the old PORTB.1 worked is that little scootch of additional time between OHI=0 and OLO=1 caused by the GOTO?

    Were there Olympic Gold for PBP help, you'd get it!
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by RussMartin View Post
    Then:

    The reason the old PORTB.1 worked is that little scootch of additional time between OHI=0 and OLO=1 caused by the GOTO?
    Exactly!

    <table><tr><td align=right>
    Were there Olympic Gold for PBP help, you'd get it!
    Hmmm, I could go for some gold ... &nbsp; &nbsp;</td><td> </td></tr></table>


    <br>
    DT

  6. #6


    Did you find this post helpful? Yes | No

    Default

    I came across the R-M-W issue today, I thought I was losing my mind. I am glad I searched the archive for 16F1827 because for the life of me I couldn't get the darn ports to set and reset after a pause statement.

    Has this problem been reported? Will it be fixed in the next PBP version update?

    I am sorry for the 20 questions, it is just that I spent 2hrs troubleshooting my hardware. When that didn't pan out I dove into getting rudimentary features to work before seeking help. All in all a dang port toggle ate up 4hrs of my day...sigh.

    Nick
    Last edited by Macgman2000; - 19th June 2010 at 01:23.

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


    Did you find this post helpful? Yes | No

    Default

    Has this problem been reported? Will it be fixed in the next PBP version update?
    It's not an issue with PBP.

    It's just the way the PIC Hardware works.
    And I assume it's why Microchip eventually added the LATx registers in the 18F's, and now the 16F1's.

    Just keep it in mind when you try to change pin states really fast and they don't work (or they affect other pins in the same port).
    Usually a minor change can fix it, even with 16F's.
    DT

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. PBP, 16F1827, FSR, and Error 113
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 13th January 2014, 09:04
  3. Can PBP & 16f88 really do 9600,8,E,1
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 38
    Last Post: - 7th November 2010, 12:12
  4. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 19:01
  5. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th December 2005, 23:30

Members who have read this thread : 2

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