I have not explained my problem properly: I want a momentary switch closure (footsw) to cause the program to jump to a loop (freq. I don't want it to jump out of the loop when the switch opens.
I have not explained my problem properly: I want a momentary switch closure (footsw) to cause the program to jump to a loop (freq. I don't want it to jump out of the loop when the switch opens.
Hi, Steve
Keep cool ... keep cool ...
Alain
Hi,Russ
Could you explain EXACTLY what you want to do ...
I mean : the switch closure lead to jump into the loop, OK ... but what happens if switch released ??? stay in the loop ??? go where ??? do you test your switch continuously after jumping off the loop ??? or just once at the beginning of your program ???
We're not at school ... no one will copy your project !!!!
Problem written is half the solution ....
Alain
Last edited by Acetronics2; - 26th May 2006 at 15:17.
************************************************** ***********************
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 " !!!
*****************************************
I want a momentary switch closure to jump to a loop and stay there, regardless of further action by the switch. Perhaps an interrupt is what I need? I don't exactly know how to do that, but will experiment. I prefer to use portb.5 for interrupt input, the data sheet says the RBIF flag will be set regardless of the state of the INTCON enable bit?
I tried this interrupt. READY is always low; when FOOTSW goes low, the freq loop runs but only as long as FOOTSW is low. When FOOTSW goes high, the clock stops; it will start again when FOOTSW goes low again. I don't understand this.
'device: 16F627A master clear is on pin#4 (RA5)
TRISA = %00010000 ' port A all outputs, except MCLR is input
TRISB = %00111111 'PORT B ALL INPUT, EXCEPT 6 & 7 OUTPUT
option_REG = %01111111 'enable weak pullups on port B
FOOTSW var portb.5 'Foot switch OR CCREADY must be high
READY var portb.4 'at start
T var word
J VAR WORD
RENCA var portb.7 'FREQUENCY OUTPUT TO J1 PIN 13
EJECT var portb.6 '100 mS PULSE TO J1 PIN 21
START:
WHILE READY = 0
LOW RENCA : LOW EJECT
on interrupt goto poo
poo:
T = 100 '1mS AT 4 mHZ
freq:
PULSOUT RENCA, T 'frequency should be 500 Hz (2mS period)
PAUSEus T*7
GOTO freq
WEND
end
Try ( to understand ) this ...
'device: 16F627A master clear is on pin#4 (RA5)
TRISA = %00010000 ' port A all outputs, except MCLR is input
TRISB = %00111111 'PORT B ALL INPUT, EXCEPT 6 & 7 OUTPUT
option_REG = %01111111 'enable weak pullups on port B
FOOTSW var portb.5 'Foot switch OR CCREADY must be high
READY var portb.4 'at start
T var word
J VAR WORD
RENCA var portb.7 'FREQUENCY OUTPUT TO J1 PIN 13
EJECT var portb.6 '100 mS PULSE TO J1 PIN 21
on interrupt goto poo
START:
LOW RENCA : LOW EJECT
WHILE READY = 0
'zzzzzzzzzzzzzzzzzzzz ... waiting !!!
WEND
GOTO what to do if not ready ???
DISABLE INTERRUPT
poo:
T = 1 '1mS AT 4 mHZ
freq:
TOGGLE RENCA
PAUSE T 'frequency should be 500 Hz (2mS period)
GOTO freq
RESUME
ENABLE INTERRUPT
end
NOTE : RESUME and ENABLE INTERRUPT are not compulsory here as program enters an endless loop ...
Alain
Last edited by Acetronics2; - 26th May 2006 at 16:57.
************************************************** ***********************
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 " !!!
*****************************************
and now we're here :
'device: 16F627A master clear is on pin#4 (RA5)
TRISA = %00010000 ' port A all outputs, except MCLR is input
PORTB = 0
TRISB = %00111111 'PORT B ALL INPUT, EXCEPT 6 & 7 OUTPUT
option_REG = %01111111 'enable weak pullups on port B
INTCON = %10001000 ' Define the interrupt origin ....YESSSS
FOOTSW var portb.5 'Foot switch OR CCREADY must be high
READY var portb.4 'at start
T var word
J VAR WORD
RENCA var portb.7 'FREQUENCY OUTPUT TO J1 PIN 13
EJECT var portb.6 '100 mS PULSE TO J1 PIN 21
on interrupt goto poo
START:
LOW RENCA : LOW EJECT
WHILE READY = 0
'zzzzzzzzzzzzzzzzzzzz ... waiting !!!
WEND
GOTO Start 'GOTO what to do if not ready ???
DISABLE INTERRUPT
poo:
IF NOT FOOTSW THEN false 'we are looking for a Portb.5 interrupt ... not PortB.4 or else
T = 1000 '1mS AT 4 mHZ ...........Note: 1000 for MPSIM, 1 for real
freq:
TOGGLE RENCA
PAUSE T 'frequency should be 500 Hz (2mS period)
GOTO freq
false:
RESUME
ENABLE INTERRUPT
end
************************************************** ***********************
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 " !!!
*****************************************
I really appreciate your help, I hope you are not tired of my dumb questions!
I tried your program; the clock starts when power is applied but nothing happens when footsw is low. When footsw goes high, the clock stops and reset will not start it. I have to turn power off and on or if I put footsw low, the clock will start again, as long as footsw is low. I put the nap statement in to see if it was seeing that part of the program; it isn't.
I don't understand the WHILE - WEND, what is that doing?
TRISB = %00111111 'PORT B ALL INPUT, EXCEPT 6 & 7 OUTPUT
option_REG = %01111111 'enable weak pullups on port B
FOOTSW var portb.5 'Foot switch OR CCREADY must be high
READY var portb.4 'at start
T var word
J VAR WORD
RENCA var portb.7 'FREQUENCY OUTPUT TO J1 PIN 13
EJECT var portb.6 '100 mS PULSE TO J1 PIN 21
on interrupt goto poo
START:
LOW RENCA : LOW EJECT
WHILE READY = 0
WEND
GOTO START
DISABLE INTERRUPT
poo:
IF NOT FOOTSW THEN FALSE
nap 6
T = 100
freq:
toggle renca 'frequency should be 500 Hz (2mS period)
PAUSEus T*7 ' 1 mS at 4 mHz
GOTO freq
false:
RESUME
ENABLE INTERRUPT
end
Bookmarks