Need 4 modes with just 3 switches - need all modes to be selectable QUICKLY!


Results 1 to 40 of 68

Threaded View

  1. #19
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Mike, K8LH View Post
    What's the purpose of diodes D2-D4 and their connection to RA2, please?
    RA2 (pin 17) on a 16F690 is the external interupt pin. So when a switch is pressed, RA2 is grounded & an interupt occurs - I then check in the interupt subroutine to see which of the three 'switch' connected pins was actually pressed (ie which one of the three switch pin also went low) - the diodes isolate the 'switched' ground from the other two pins not pressed.

    It essentially allows you to implement three physical pins (or more) to be 'psuedo'-interupt pins (vs just the one ext interupt that the 16f690 has)

    All credit to forum members on this thread for filling me in on how to do it....

    http://www.picbasic.co.uk/forum/show...9900#post89900

    Quote Originally Posted by Kamikaze47 View Post
    Ahh, right. I was assuming you were setting that pin high. Makes sense now.
    RA2 (pin 17) is set high...but high via an internal weak pullup (at the risk of teaching grannie to suck eggs, note the lack of the word 'resistor' on the end of that phrase - apparently not a resistor, but some silicon junction internal to the PIC providing the resistance here)

    Just for the record, any similar noobs like me, who may find this thread via a search, here are the 16F690 register settings needed to bring the weak pullups into play (obviously change the 1 & 0s of wht WPUA & WPUB registers to suit your own external connections)

    Code:
    OPTION_REG.7 = 0         'enable weak pullups.
    WPUA         = %00000110  'activate weak pullups on RA1 & RA2.
    WPUB         = %01100000  'activate weak pullups on RB5 & RB6.
    Last edited by HankMcSpank; - 6th August 2010 at 18:41.

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