Announcement

Collapse
No announcement yet.

PIC16F722A Port B Internal Pull-up problems

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PIC16F722A Port B Internal Pull-up problems

    I am close to exhausting all the pin assignments on a 16F722 but think I am making pretty good use of the chip's capabilities.

    I have 6 sensor and button inputs and to reduce external components I decided to make full use of the PIC's weak pull-ups on port B by assigning these functions to PortB pins.

    Problem is only 4 out of the 6 (B.0 - B.5) are giving me correct results. I refer to the diagram and screen shots below:
    Click image for larger version

Name:	Trolley Control II Pinouts.jpg
Views:	107
Size:	61.5 KB
ID:	7570
    Click image for larger version

Name:	Port B assignments.jpg
Views:	78
Size:	19.2 KB
ID:	7571
    I have turned off analog functions on PortB in an assembly sequence from the PIC docs.
    I have set the global PortB pullup bit in Option Register
    I have defined the specific bits with WPUB
    I have set TrisB=%111111 even though I am dedicating B.6 and B.7 exclusively to ICSP.

    When I do a simple test on all of the pins individually pins B.3 and B.5 remain low and fall through the While statement. I check the pins with my logic probe and they are indeed low at the point the While executes.

    Click image for larger version

Name:	Init and Test.jpg
Views:	77
Size:	67.4 KB
ID:	7572
    In trying to eliminate issues, I looked into disabling the CPS module which is multiplexed on B.3 - B.5 but the module is disabled by default at startup. The only thing I haven't tried yet is disabling CCP2 but that only affects the B.3 pin.

    I'm running out of ideas here. Any thoughts? I didn't send all the code because there is a bunch of it that I am just branching around for this test and it should have no effect. I suppose I could send a stripped down version with just the troublesome part if it was deemed necessary.




  • #2
    don't know what you expect
    code posted as a image ,who has got time to retype all that .
    asm code not in an asm block .
    code that tests only one of the pins in question and fails to demonstrate any issue that i can see

    might i suggest code in code tags , code thats compilable and demonstrates the issue

    Comment


    • #3
      Note that they are described as "weak" pullups. When I last tested, they were about as effective as 1M resistors. Depending on the hardware, you might need external resistors. Are you checking the voltages when the pins are isolated from the rest of the circuit?

      If I remember correctly, "OPTION_REG = %00000000" isn't a good thing. I think its default is %11111111, so you're changing a lot of things that you might not intend, including the watchdog prescaler assignment.

      You don't need to use Assembly to set SFR values. PBP knows the names of TRISB, PORTB and ANSELB just like it knows OPTION_REG and WPUB.

      The "code tag" that Richard mentioned is the # button on the advanced editor tool bar. When used on highlighted text, it changes it to a font that is more suitable to code, like so:

      Code:
      OPTION_REG.7 = 0
      WPUB = %00111111
      PORTB = 0
      ANSELB = 0
      TRISB = %11111111

      Charles Leo
      ME Labs, Inc.
      http://melabs.com

      Comment


      • #4
        Richard and Leo,

        Thank you both for your comments.

        I change the line that tests WSen above to each of the 6 vars in turn, re-compile and re-program for each. I suppose this is unthinkable in a production environment but since my environment is strictly an educational one some repetition is expected.

        Leo thanks for the code example. I know better that setting OPTION_REG to 00000000 was a hazardous thing to do but some days I just do illogical things and then keep overlooking it! I have also seen the bit setting method for SFR's but I seem to have forgotten that easy solution. Comes from not doing this every day.

        As far as using the block of assembly code to set ANSEL and TRIS, well I inserted that in my part proto-type files when I was studying assembly and it has worked ever since so I never swapped it for the PBP code.

        Nobody will ever accuse me of being an efficient coder!

        I think it might be best to use external PU's since I have always had good results with them. Real estate on the board is abundant. It is good to know that weak PU resistance is around 1M.

        Comment


        • #5
          The datasheet for the 16f722A lists the WPU current to between 50uA and 400uA at 5V. That's 100k worst case so 1M seems way out of - at least for this particular part, I haven't checked others. Have you measured it on the pins that does seem to work?

          /Henrik.

          Comment

          Working...
          X