
Originally Posted by
Mike, K8LH
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

Originally Posted by
Kamikaze47
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.
Bookmarks