Hello Thrix
Thrix, a couple of things ok?
1. I do not have anyway how to test this ok?
Now. 2nd thing.... I noticed that you used the variables I-N for some For-Next Loops. Well I also noticed that none of these loops were nested. That means you can use 1 variable for *all* the loops (for this program example only that you gave).
Now the 3rd thing.... I Noticed that you were only Toggling 5 ports on and off... Nothing more. So what I did, was put every one of your toggles into a SubRoutine. When I want to Toggle that port, I just call that subroutine. This probably cut the number of lines in your code by 1/3.
Since I have no way of checking the program against something, I may have errored in reading your code. I also noticed a Loop: and a Goto Loop: Those seemed redundant, because at the end of your program you have Goto Main. It is also not wise to jump in the middle of a For/Next loop with a goto *outside* the for/next loop.
Here is what i think the code may look like after the above points are implimented:
I VAR WORD 'DELAY FOR ALL COLUMN DISPLAY
TRISA = 255
TRISB = 0
MAIN:
FOR I = 0 TO 25
' DISPLAYING AT ALL COLUMN
PORTB = $7F ''''''''''''''''''
GoSub TogPA4
PORTB = $8
GoSub TogPA3
PORTB = $8
GoSub TogPA2
PORTB = $8
GoSub TogPA1
PORTB = $7F 'STARTING POINT
GoSub TogPA0
NEXT I
'SHIFT NO 1 TO LEFT
FOR I = 0 TO 25
PORTB = $8
GoSub TogPA0
PORTB = $8
GoSub TogPA1
PORTB = $8
GoSub TogPA2
PORTB = $7F 'END POINT
Gosub TogPA3
NEXT I
'SHIFT LEFT NO 2
FOR I = 0 TO 25
PORTB = $8
gosub TogPA0
PORTB = $8
GoSub TogPA1
PORTB = $7F ' END POINT
Gosub TogPA2
' --------------> ' COLUMN 3 IS HIGH
PORTB = $7F ' STARTING POINT
GoSub TogPA4
NEXT I
'SHIFT LEFT NO 3
FOR I = 0 TO 25
PORTB = $8
GoSub TogPA0
PORTB = $7F 'END POINT
GoSub TogPA1
PORTB = $7F ' STARTING POINT
GoSub TogPA3
PORTB = $8
GoSub TogPA4
NEXT I
'SHIFT LEFT NO 4
FOR I = 0 TO 25
PORTB = $7F 'END POINT
GoSub TogPA0
PORTB = $7F ' STARTTING POINT
GoSub TogPA2
PORTB = $8
GoSub TogPA3
PORTB = $8
GoSub TogPA4
NEXT I
'SHIFT LEFT NO 5
FOR I = 0 TO 25
PORTB = $7F 'STARTING POINT
GoSub TogPA1
PORTB = $8
GoSub TogPA2
PORTB = $8
GoSub TogPA3
PORTB = $8
GoSub TogPA4
NEXT I
goto MAIN
;subroutines!!!!!!!!!!
TogPA4:
LOW PORTA.4 ' END POINT '
PAUSE 3 ' '
HIGH PORTA.4 ''''''''''''''''''
return
TogPA3:
LOW PORTA.3
PAUSE 3
HIGH PORTA.3
return
TogPA2:
LOW PORTA.2
PAUSE 3
HIGH PORTA.2
return
TogPA1:
LOW PORTA.1
PAUSE 3
HIGH PORTA.1
return
TogPA0:
LOW PORTA.0
PAUSE 3
HIGH PORTA.0
return
' Go back to loop and blink LED forever
End
Bookmarks