FOR sequence is skipped


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2006
    Location
    In a world of german electrons
    Posts
    102

    Angry FOR sequence is skipped

    Hello. I wrote this piece of code to test PBP:

    Code:
    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:

    Code:
    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 ?
    Last edited by selbstdual; - 8th August 2006 at 22:25.

  2. #2
    Join Date
    Jul 2005
    Location
    Midwest
    Posts
    81


    Did you find this post helpful? Yes | No

    Default

    try making t and wh word sized variables

  3. #3
    Join Date
    Aug 2006
    Location
    In a world of german electrons
    Posts
    102


    Did you find this post helpful? Yes | No

    Default

    it works thank you

  4. #4
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Inn addition to Steve's,

    also consider this:

    Code:
    FOR t=2000 TO 25 STEP - 1
    
    ......
    
    next t



    ---------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  5. #5
    Join Date
    Aug 2006
    Location
    In a world of german electrons
    Posts
    102


    Did you find this post helpful? Yes | No

    Default

    Okay. Thank you.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts