PDA

View Full Version : FOR sequence is skipped



selbstdual
- 8th August 2006, 21:22
Hello. I wrote this piece of code to test PBP:



Start:
YellowLED VAR PORTB.0
RedLED VAR PORTB.1
t VAR BYTE
WH VAR BYTE

High CMCON.0
High CMCON.1
High CMCON.2

HIGH STATUS.0
TRISB = %00000000
TRISA = %00000000
Low STATUS.0
High YellowLED ;LED Starting sequence
High RedLED
PAUSE 2000
Low YellowLED
Low RedLED
PAUSE 2000


FOR t=20000 TO 250 STEP - 1
High RedLED
PAUSE 100
FOR WH=0 TO 2000 STEP 1
PAUSE 20
High YellowLED
PAUSE 100
Low YellowLED
NEXT WH
Low RedLED
NEXT t

GO:
High RedLED
High YellowLED
PAUSE 500
Low RedLED
Low YellowLED
PAUSE 500
GOTO GO


Unfortunately it acts as if there is no "FOR" present. So what it does is the following:




Start:
YellowLED VAR PORTB.0
RedLED VAR PORTB.1
t VAR BYTE
WH VAR BYTE

High CMCON.0
High CMCON.1
High CMCON.2

HIGH STATUS.0
TRISB = %00000000
TRISA = %00000000
Low STATUS.0
High YellowLED ;LED Starting sequence
High RedLED
PAUSE 2000
Low YellowLED
Low RedLED
PAUSE 2000

GO:
High RedLED
High YellowLED
PAUSE 500
Low RedLED
Low YellowLED
PAUSE 500
GOTO GO



How to solve this ?

Steve_88
- 8th August 2006, 21:47
try making t and wh word sized variables

selbstdual
- 9th August 2006, 00:06
it works thank you

sayzer
- 9th August 2006, 07:59
Inn addition to Steve's,

also consider this:



FOR t=2000 TO 25 STEP - 1

......

next t






---------

selbstdual
- 10th August 2006, 02:35
Okay. Thank you.