2 program in one BS2
irivine
Posts: 18
Currently i am working on a project that uses BS2 , having 2 program ...
i am adding a slide switch to pin 1 of bs2 which will enable me to switch between 2 program for example when pin 1 = 1 , it will go to routine 1 , if not i will goto routine 2
i wonder if this actually works , because i am having some problem that the programs are not switching
i wonder if this doesn't work because the voltage to the switch is not hign enough for the pin to be 1
could the way i am putting the switch affecting the program switching
help need ! thanks !!
the following is the code i am doing
i am adding a slide switch to pin 1 of bs2 which will enable me to switch between 2 program for example when pin 1 = 1 , it will go to routine 1 , if not i will goto routine 2
i wonder if this actually works , because i am having some problem that the programs are not switching
i wonder if this doesn't work because the voltage to the switch is not hign enough for the pin to be 1
could the way i am putting the switch affecting the program switching
help need ! thanks !!
the following is the code i am doing
Comments
It's not very helpful to say "actually works" or "doesn't work" or "some problem". It's much more useful to say what appears to happen to the program when the switch is in one setting or the other setting like "When I set the switch so it connects the I/O pin to ground, the program takes the proper path. When I set the switch to the other setting, it takes the wrong path.".
so in this case , i use a pushbutton with the active-high circuit
and with the following code
Main:
if(pin 1 = 1) GOTO ROUTINE ONE ELSE GOTO ROUTINE TWO
ROUTINE ONE:
RETURN
ROUTINE TWO:
RETURN
will this work ?
You can have two routines
This is what I have found is if your routines are very different then you will have a lot of trouble getting this to work unless you only change the routines at Power Up
This is an example of what I am talking about
(Power_ON·)··is different form·(·Power_OFF )·
power_on has power
and
power_off dose not power
This is for I\O pin 14· (·IN14 )·
Pick_ONE:
DO
DEBUG CLS
IF IN14 = 0 THEN
·· GOSUB Power_ON
ELSE
·· GOSUB Power_OFF
ENDIF
LOOP
Power_ON:
·
DO WHILE IN15 = 1
·
GOSUB Show_Time
GOSUB Show_State_Power_ON
LOOP
DO WHILE IN15 = 0
·
GOSUB Halt_clock
GOSUB Display_Time
GOSUB Show_State_Power_ON
·LOOP
·
GOSUB Restart_clock
GOSUB Power_Restarts
GOSUB Power_ON
RETURN
Power_Off:
DO
·GOSUB Show_Time
·GOSUB Show_State_Power_OFF
·
·LOOP UNTIL IN15 = 1
·DO
·GOSUB Display_Time
·GOSUB Halt_clock
·GOSUB Show_State_Power_OFF
·
LOOP UNTIL IN15 = 0
·
GOSUB Restart_clock
GOSUB Power_restarts:
GOTO Power_Off
RETURN
·
Show_State_Power_ON:
DEBUG "· Show_State_Power_ON· "
·IF IN15 = 0 THEN
·SEROUT LCD, Baud, [noparse][[/noparse]DispLightOff]
PAUSE 1
ELSEIF IN15 = 1 THEN
SEROUT LCD, Baud, [noparse][[/noparse]DispLightOn]
PAUSE 1
ENDIF
DEBUG DEC3 restarts, "·· r"
RETURN
Show_State_Power_OFF:
DEBUG "· Show_State_Power_OFF· "
·IF IN15 = 0 THEN
·SEROUT LCD, Baud, [noparse][[/noparse]DispLightOn]
PAUSE 1
ELSEIF IN15 = 1 THEN
SEROUT LCD, Baud, [noparse][[/noparse]DispLightOff]
PAUSE 1
ENDIF
Halt_clock:
·reg = $80········· ' Point to register 80h
·ioByte = %10000000 ' Set Clock Halt Bit
·GOSUB RTC_Out····· ' Send Command
·RETURN
Restart_clock:
·reg = $80········· ' Point to register 80h
·ioByte = %0110000 ' starts the clock by clearing the Clock Halt bit and clears the minutes to "00"
·GOSUB RTC_Out····· ' Send Command
·RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 1/25/2009 2:06:36 AM GMT
sry i am still now sure what is it about
so i must always have the halt_clock and restart_clock no matter what i
currently i am still a secondary school student
can i have some guidance with reference to my circuit?
thank you for ur help