You must switch PortA to digital-I/O, after a Reset it will be only analog-in !
Just see the docs !
You must switch PortA to digital-I/O, after a Reset it will be only analog-in !
Just see the docs !
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
Thanks BigWumpus, i tried this, but still no luck.
Ideally i want to monitor lines RC0, RC1, RC2, RC6, RC7 and RA0 (can't use RC3 as there isn't one and RC4 & 5 are used for USB. When a switch is depressed on one of theses lines it jumps to a corresponding sub routine.
I've got the Case Select routine working for RC0-2 but am struggling with the rest, particulalry as it loks at a different PORT.
Can anyone help please?
Thanks,
Check the documentation around ADCON1 to switch PortA from analog to digital.
Your Case-statement looks fine, but is very very big in code !
(You have to calculate the MaskSwitch out of 2 numbers!)
Whats about this:
-----
Button1 Var PortC.0
Button2 Var PortC.1
...
Button7 Var PortA.0
ADCON1=%00001111
If Button1 Then
If Circle = 1 Then Gosub Procedure_Circle
Endif
If Button2 Then
If ...
Endif
-----
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
Thanks for you help BigWumpus. I wanted to avoid using multiple IF..THEN statements as the 'cleaner' way is supposed to be using a CASE SELECT.
However, this is where i fall down. I am having difficulty using the CASE SELECT with multiple PORTS.
Obvioulsy if it can't be done then i have the multiple IF...THENS but i think with 5 or 6 buttons (or HIGH inputs as they will be), the code will be much bigger then using a structured CASE SELECT.
Cheers,
Steve
Hello,
the complicated way:
MaskSwitch=(PortC & %00000111) | ((PortC & %11000000) >> 3) | ((PortA.0 & %00000001) << 5)
The better way (using the bit-operators of PICs):
MaskSwitch=0
If PortC.0 Then MaskSwitch.0=1
If PortC.1 Then MaskSwitch.1=1
If PortC.2 Then MaskSwitch.2=1
If PortC.6 Then MaskSwitch.3=1
If PortC.7 Then MaskSwitch.4=1
If PortA.0 Then MaskSwitch.5=1
Check out the size !!!
But be aware to press more then ONE key !!!
Then you have to write multiple case-lines !!! ;-)
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
OK, So the second options is still using the CASE SELECT method is it?
Does this mean that the statement will look as follows:
ie, does the MaskSwitch.1 represent Case 1 value, MaskSwitch.2 represent Case 2 etc etc?Code:Button1 Var PORTC.0 Button2 Var PORTC.1 Button3 Var PORTC.2 Button4 Var PORTC.6 Main: MaskSwitch=0 If PORTC.0 Then MaskSwitch.0=1 If PORTC.1 Then MaskSwitch.1=1 If PORTC.2 Then MaskSwitch.2=1 If PORTC.6 Then MaskSwitch.3=1 Select Case MaskSwitch Case 0 If Button1 = 1 Then Gosub Procedure_Button1 If Button1 = 0 THEN EndIf Case 1 If Button2 = 1 Then Gosub Procedure_Button2 If Button2 = 0 THEN EndIf Case 2 If Button3 = 1 Then Gosub Procedure_Button3 If Button3 = 0 THEN EndIf .......
Many thanks again,
Steve
No,
like your first posting, the maskswitch is:
1, 2, 4, 8, 16, 32 ....
or binary:
%00000001, %00000010, %00000100, %00001000, ...
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
Bookmarks