Hi, Sayzer
I do not want to use sims ... lol
BTW :
This kind of structure can't work properly ... as the second part never can be reached !!! ( or toggling button in less than 1µs ... )
...
IF PORTB.0=0 then
HIGH PORTB.4
WHILE PORTB.0=0 : Wend : pause 50
ENDIF
IF PORTB.0=0 then
LOW PORTB.4
WHILE PORTB.0=0 : Wend : pause 50
ENDIF
...
Button state AND its corresponding output state must be tested at the same time ... to take the appropriate action.
Alain
Last edited by Acetronics2; - 29th August 2009 at 10:09.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Sorry ...
was not 1µs but 50 ms ...or toggling button in less than 1µs ...
but result is the same !!!
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
' Test I/O Ports Input and Output
SW1 var PORTB.0
SW2 var PORTB.1
SW3 var PORTB.2
SW4 var PORTB.3
LED1 VAR PORTD.0
LED2 VAR PORTD.1
LED3 VAR PORTD.2
LED4 VAR PORTD.3
i var byte
DEFINE OSC 48
'------- Initial IO Ports -------
TRISB = $FF
TRISD = 0
CMCON = 0
ADCON1 = 7
'------- Main Function -------
main:
LED1 = SW1
LED2 = SW2
LED3 = SW3
LED4 = SW4
goto main
Try this
Code:start: IF PORTB.0=0 then toggle PORTB.4 WHILE PORTB.0=0 : Wend : pause 50 ENDIF IF PORTB.1=0 then toggle PORTB.5 WHILE PORTB.1=0 : Wend : pause 50 ENDIF IF PORTB.2=0 then toggle PORTB.6 WHILE PORTB.2=0 : Wend : pause 50 ENDIF IF PORTB.3=0 then toggle PORTB.7 WHILE PORTa.3=0 : Wend : pause 50 ENDIF goto start
Place a 330 ohms in series to each leds (as suggested in previuos post), and use Toggle command (as suggested in previuos post).
Code:start: Pause 50 IF PORTB.0=0 then Toggle PORTB.4 ENDIF IF PORTB.1=0 then Toggle PORTB.5 ENDIF IF PORTB.2=0 then Toggle PORTB.6 ENDIF IF PORTB.3=0 then Toggle PORTB.7 ENDIF HoldLoop: If PortB & %00001111 != 15 then HoldLoop goto start
Al.
Last edited by aratti; - 31st August 2009 at 12:25.
All progress began with an idea
Bookmarks