bigal_scorpio
Active Member
Hi again guys,
due to all the previous help I now have a somewhat working program but it is doing something I can't figure out and am only a beginner with Pics.
When I turn on I expected the program to wait until a button (up or down) was sent high ( I have internal pullups off and the pins pulled low on my dev board - EasyPic5) but the prog just runs through past the button command to the pulses and never stops.
What am I doing wrong?
I am using a 12F629 Pic btw, here is the code.
program stepper992
main:
DIM t as byte
WPU = %00000000 'turn off weak pullups
TRISIO =%00101000 'set GPIO 0,1,2,4 as out and 3,5 as inputs
GPIO = %00000000 'turn off all outputs
CMCON =0x07 'set comparator to off
IF BUTTON(GPIO,5,1,0)then GOTO up 'check for button press for up
END IF
IF BUTTON(GPIO,3,1,0)then GOTO down 'check for button press for down
END IF
GOTO main 'if no presses then restart
up:
FOR t = 1 to 5
GPIO = %00010001 'Set on bits for this pulse
delay_ms (110)
GPIO = %00000011 'Set on bits for this pulse
DELAY_MS (110)
GPIO = %00000110 'Set on bits for this pulse
delay_ms (110)
GPIO = %00010100 'Set on bits for this pulse
DELAY_MS (110)
NEXT t
GOTO main 'After completing pulses return to start
down:
FOR t = 1 to 5
GPIO = %00010100 'Set on bits for this pulse
delay_ms (110)
GPIO = %00000110 'Set on bits for this pulse
DELAY_MS (110)
GPIO = %00000011 'Set on bits for this pulse
delay_ms (110)
GPIO = %00010001 'Set on bits for this pulse
DELAY_MS (110)
NEXT t
GOTO main 'After completing pulses return to start
end.
Thanks for looking........Al
due to all the previous help I now have a somewhat working program but it is doing something I can't figure out and am only a beginner with Pics.
When I turn on I expected the program to wait until a button (up or down) was sent high ( I have internal pullups off and the pins pulled low on my dev board - EasyPic5) but the prog just runs through past the button command to the pulses and never stops.
What am I doing wrong?
I am using a 12F629 Pic btw, here is the code.
program stepper992
main:
DIM t as byte
WPU = %00000000 'turn off weak pullups
TRISIO =%00101000 'set GPIO 0,1,2,4 as out and 3,5 as inputs
GPIO = %00000000 'turn off all outputs
CMCON =0x07 'set comparator to off
IF BUTTON(GPIO,5,1,0)then GOTO up 'check for button press for up
END IF
IF BUTTON(GPIO,3,1,0)then GOTO down 'check for button press for down
END IF
GOTO main 'if no presses then restart
up:
FOR t = 1 to 5
GPIO = %00010001 'Set on bits for this pulse
delay_ms (110)
GPIO = %00000011 'Set on bits for this pulse
DELAY_MS (110)
GPIO = %00000110 'Set on bits for this pulse
delay_ms (110)
GPIO = %00010100 'Set on bits for this pulse
DELAY_MS (110)
NEXT t
GOTO main 'After completing pulses return to start
down:
FOR t = 1 to 5
GPIO = %00010100 'Set on bits for this pulse
delay_ms (110)
GPIO = %00000110 'Set on bits for this pulse
DELAY_MS (110)
GPIO = %00000011 'Set on bits for this pulse
delay_ms (110)
GPIO = %00010001 'Set on bits for this pulse
DELAY_MS (110)
NEXT t
GOTO main 'After completing pulses return to start
end.
Thanks for looking........Al