PBP & 16F690 bug?


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373

    Default PBP & 16F690 bug?

    I am working with the 16F690 in the new micro QFN 20 package. It works fine but displays a wierd bug with the PBP shiftout function. I use pin RB6 as the shift clock, RC7 as the shift data output and RB4 as data in(not used at this point). RB5 is an LED output to show that there is shiftout communication. I set it high, shiftout a few bytes, look for a button press, and when the button is released, turn the LED back off by clearing the bit.
    Now, here's the problem... When the shiftout command is called, RB5 is immedietly cleared, effectively turning the LED off. I have bypassed the shiftout statements and the LED stays high. I tried another LED on RC4 and it worked fine. The code is just a couple of lines, and the RB5 pin is definitely cleared when entering shiftout. I will post it if need be, but it is extremely simple. I have even tried substituting while-when for the if-then button sheck statement.
    Eventually I will go to hardware SPI, but for versatility, would like to get this working. Any ideas?

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Have you disabled the Analog stuff on PORTB.4 and PORTB.5 ?

    ANSELH=0
    Last edited by mister_e; - 27th May 2006 at 16:01.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    Yes sir. I cleared the ANSEL register. Wow...Quick response!

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Sorry i just edited above... ANSELH=0
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    Sorry i just edited above... ANSELH=0
    I did ANSEL, not ANSELH. Why would the pin revert to a 0/input when invoking shiftout even if ANSELH is high?

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    As they are analog by default, i guess it's one of those weird thing it could do. But Why B.5 when the Clock signal apear on B.6.... because of the combination of the external load, Capacitance, TRIS switching AND internal A/D multiplexer i guess... i didn't spend too much time in the datasheet to study how it could happen but if the ANSELH is not cleared, those pin will certainely be analog, not digital as you want.

    You know, sometimes it's better to don't know all the reasons and stay happy when it works

    It's just weird that they didn't place the ANSEL and ANSELH register in the A/D datasheet section...
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    As they are analog by default, i guess it's one of those weird thing it could do. But Why B.5 when the Clock signal apear on B.6.... because of the combination of the external load, Capacitance, TRIS switching AND internal A/D multiplexer i guess... i didn't spend too much time in the datasheet to study how it could happen but if the ANSELH is not cleared, those pin will certainely be analog, not digital as you want.

    You know, sometimes it's better to don't know all the reasons and stay happy when it works

    It's just weird that they didn't place the ANSEL and ANSELH register in the A/D datasheet section...
    Thanks, I'll try the fix tonight. Wierd quirk though...Huh?

  8. #8
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    As they are analog by default, i guess it's one of those weird thing it could do. But Why B.5 when the Clock signal apear on B.6.... because of the combination of the external load, Capacitance, TRIS switching AND internal A/D multiplexer i guess... i didn't spend too much time in the datasheet to study how it could happen but if the ANSELH is not cleared, those pin will certainely be analog, not digital as you want.

    You know, sometimes it's better to don't know all the reasons and stay happy when it works

    It's just weird that they didn't place the ANSEL and ANSELH register in the A/D datasheet section...
    I cleared the ANSELH register to 0 and all is right with the world...Thanks for the help.

    Ron

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Great to know it's working. It's not often i saw TWO ANSEL registers so.. kinda interesting to know it exist
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Sep 2003
    Location
    Vermont
    Posts
    373


    Did you find this post helpful? Yes | No

    Exclamation

    An interesting aside to this saga. Jeff from Melabs emailed me back about this quirk. This is important for anyone using Analog inputs with digital outputs. When the uP is commanded to change a bit, it reads, modify,writes the entire port. Since Analog bits are read as zero, when the port is rewritten, any Analog bit will be written as a zero. Even if it was used as a digital high output,as was in my case. Verrrry interesting!

    Ron

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. pbp bug or incompetence?
    By George in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th June 2008, 23:33
  3. BUG IN PBP 2.50 & 2.50A pic16F688 ??
    By FRANCISCOGIM in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 12th June 2008, 02:42
  4. PBP bug ???
    By boban in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th March 2008, 16:30
  5. 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

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