hotstepper
07-21-04, 03:57 PM
Hi
My application demands that I call a specific sub-routine when certain conditions are satisfied. To check for the program structure, I have tried a sample program where I toggle the LEds based on what input I recieve over the serial port. The program works fine, but I have observed that it sometimes get stuck in a sub-routine and the control is not returned back to the calling routine as expected.
What I am trying to do is, toggle the RED, GRN, YEL LEDs based on the inputs from the keyboard ( simulating data recieved on the serial port ) letters R, G, Y respectively. Now, according to my code on pressing any of these keys once the corresponding LED has to blink. There is a delay between switching the LED OFF and switching it ON again. The delay statement used has been picked up from a sample program downloaded from this site. On running the program continuously it sometimes happens that it gets stuck in any of the sub-routines. I say this as the LED doesnt toggle and successive inputs are just ignored. Can you please go through the program code and let me know where I am going wrong.
------------------------------------------------------------------------------------
VARIABLE X
MACHINE MAC
ON-MACHINE MAC
APPEND-STATE ST1
APPEND-STATE ST2
: WAIT ( -- ) TCFTICKS @
BEGIN
TCFTICKS @ OVER -
100 > UNTIL
DROP
; EEWORD
: LOOPRED
REDLED OFF
WAIT
REDLED ON
; EEWORD
: LOOPGRN
GRNLED OFF
WAIT
GRNLED ON
; EEWORD
: LOOPYEL
YELLED OFF
WAIT
YELLED ON
; EEWORD
IN-STATE ST1
CONDITION
CAUSES SCI0 RX X !
THEN-STATE ST2 TO-HAPPEN
IN-STATE ST2
CONDITION
CAUSES X @ 71 = IF
LOOPGRN
THEN
X @ 89 = IF
LOOPYEL
THEN
X @ 82 = IF
LOOPRED
THEN
THEN-STATE ST1 TO-HAPPEN
: START
SET-STATE ST1
INSTALL MAC
EVERY 5000 CYCLES SCHEDULE-RUNS MAC
;
------------------------------------------------------------------------------------
I also have doubts about the WAIT routine. I have gone through the explanation for TCFTICKS in the manual and tried changing the period to 50000 using
DECIMAL 50000 PERIOD
and there by giving a value of 600 in the WAIT routine, to count 6seconds. But, my observation says that the WAIT routine holds for no more than 2 seconds at this value. Can you please help me out with this as well, I mean how do I exactly measure 1 second programatically using IsoMAx.
Thanks
Hotstepper
My application demands that I call a specific sub-routine when certain conditions are satisfied. To check for the program structure, I have tried a sample program where I toggle the LEds based on what input I recieve over the serial port. The program works fine, but I have observed that it sometimes get stuck in a sub-routine and the control is not returned back to the calling routine as expected.
What I am trying to do is, toggle the RED, GRN, YEL LEDs based on the inputs from the keyboard ( simulating data recieved on the serial port ) letters R, G, Y respectively. Now, according to my code on pressing any of these keys once the corresponding LED has to blink. There is a delay between switching the LED OFF and switching it ON again. The delay statement used has been picked up from a sample program downloaded from this site. On running the program continuously it sometimes happens that it gets stuck in any of the sub-routines. I say this as the LED doesnt toggle and successive inputs are just ignored. Can you please go through the program code and let me know where I am going wrong.
------------------------------------------------------------------------------------
VARIABLE X
MACHINE MAC
ON-MACHINE MAC
APPEND-STATE ST1
APPEND-STATE ST2
: WAIT ( -- ) TCFTICKS @
BEGIN
TCFTICKS @ OVER -
100 > UNTIL
DROP
; EEWORD
: LOOPRED
REDLED OFF
WAIT
REDLED ON
; EEWORD
: LOOPGRN
GRNLED OFF
WAIT
GRNLED ON
; EEWORD
: LOOPYEL
YELLED OFF
WAIT
YELLED ON
; EEWORD
IN-STATE ST1
CONDITION
CAUSES SCI0 RX X !
THEN-STATE ST2 TO-HAPPEN
IN-STATE ST2
CONDITION
CAUSES X @ 71 = IF
LOOPGRN
THEN
X @ 89 = IF
LOOPYEL
THEN
X @ 82 = IF
LOOPRED
THEN
THEN-STATE ST1 TO-HAPPEN
: START
SET-STATE ST1
INSTALL MAC
EVERY 5000 CYCLES SCHEDULE-RUNS MAC
;
------------------------------------------------------------------------------------
I also have doubts about the WAIT routine. I have gone through the explanation for TCFTICKS in the manual and tried changing the period to 50000 using
DECIMAL 50000 PERIOD
and there by giving a value of 600 in the WAIT routine, to count 6seconds. But, my observation says that the WAIT routine holds for no more than 2 seconds at this value. Can you please help me out with this as well, I mean how do I exactly measure 1 second programatically using IsoMAx.
Thanks
Hotstepper