I have a simple ASM program with a matrix display light just columns. An example:
;-----------------------
LIST P=16F876
#include <p16F876.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ORG 0x2100
DE 0x00
ORG 0
cblock 0x20
d1
d2
d3
endc
goto start
Delay
;999990 cycles
movlw 0x07
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
;4 cycles (including call)
return
loop:
movlw b'00000111'
movwf PORTA
movlw b'11110010'
movwf PORTB
movlw b'11111111'
movwf PORTC
call Delay
call Delay
call Delay
goto loop
start:
bsf STATUS,RP0 ; select register page 1
movlw 0 ; put 0 into W
movwf TRISC ; set portC all output
clrf TRISA
clrf TRISB
bsf STATUS,RP1 ; select Page 2,
bcf STATUS,RP0 ; by setting RP1 in Status register and clearing RP0
clrf PORTC ; select Digital I/O on port C
bcf STATUS,RP1 ; back to Register Page 0
goto loop
end
;-----------------------
This program code is OK . But I want the program to which I could display the words fleeing across the screen. Started, I tried to ignite a pair of columns on different sites but with the burning LEDs. But received some strange flashing, do not light longer ... Anybody know what's wrong ...
Programme code:
;-----------------------
LIST P=16F876
#include <p16F876.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ORG 0x2100
DE 0x00
ORG 0
cblock 0x20
Delay1 ; delay loop 1
Delay2 ; delay loop 2
Delay3 ; delay loop 3
TimeDelay ; time delay x 0.001 s
EndCount ; used to tell PIC the end of the table is reached
Counter ; used as table counter
Line1 ; Line 1
Line2 ; Line 2
Line3 ; Line 3
Line4 ; Line 4
Line5 ; Line 5
sad
Line6 ; Line 6
Line7 ; Line 7
Line8 ; Line 8
Layer4 ; brightness, and time
Brightness ; LED brightness
Time ; time for each pattern to stay
Temp ; temp register
d1
d2
d3
endc
goto start
Delay
;999990 cycles
movlw 0x17
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
;4 cycles (including call)
return
loop:
movlw b'00000001'
movwf Line1
movlw b'11110010'
movwf Line2
call output
call Delay
movlw b'11100000'
movwf Line1
movlw b'10101010'
movwf Line2
call output
call Delay
goto loop
start:
bsf STATUS,RP0 ; select register page 1
movlw 0 ; put 0 into W
movwf TRISC ; set portC all output
clrf TRISA
clrf TRISB
bsf STATUS,RP1 ; select Page 2,
bcf STATUS,RP0 ; by setting RP1 in Status register and clearing RP0
clrf PORTC ; select Digital I/O on port C
bcf STATUS,RP1 ; back to Register Page 0
goto loop
output:
movfw Layer4
andlw b'00000001'
movwf Time
incf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
clrf PORTB ; clear port B
movfw Line1 ; move layer1 to W
movwf PORTC ; put W onto PortC
bsf PORTB,4 ; turn on layer 1 buy outputing bit 5 of PortB
movfw Brightness ; put brightness into W
call Delayy ; call the delay
bcf PORTB,4 ; turn off layer 1
movfw Brightness ; put Brightness into W
sublw 4 ; sub W from 4
btfss STATUS,Z ; skip if the zero flag is set
call Delayy ; call the delay
decfsz Time
clrf PORTB ; clear port B
movfw Line2 ; move Line2 to W
movwf PORTC ; put W onto PortC
bsf PORTB,5 ; turn on layer 2 buy outputing bit 6 of PortB
movfw Brightness ; put brightness into W
call Delayy ; call the delay
bcf PORTB,5 ; turn off layer 2
movfw Brightness ; put Brightness into W
sublw 4 ; sub W from 4
btfss STATUS,Z ; skip if the zero flag is set
call Delayy ; call the delay
decfsz Time
decfsz Time ; decrement the Time regiester
return
Delayy:
movwf Delay3 ; put W into Delay 3
Loop1:
; After Delay2 decreses to 0, it is reset to..
movlw 0x1 ; put 1 into W
movwf Delay2 ; put W into Delay2
Loop2:
; After Delay1 decreses to 0, it is reset to E9h
movlw 0x1D ; put 80 into W
movwf Delay1 ; put W into Delay1
Loop3:
decfsz Delay1 ; decrement Delay1
goto Loop3 ; jump back to Loop3
decfsz Delay2 ; decrement Delay2
goto Loop2 ; jump back to Loop2
decfsz Delay3 ; decrement Delay3
goto Loop1 ; jump back to Loop1
return
end
;----------------------------------------------------------
Thanks for help.
REPLY
[flag][delete]
2
Jan 9, 2011. 7:48 AMhemmikarl (author) says:
A part of your problem might be the
Delayy:
that your subroutine is called but you call Delay on some parts of your code
The other part of your problem might be that you clear PORTB in the call of outputs
The code does not put PORTC all to 0 before it starts outputting so that might be a part of your problem
If it´s neither of those then I'm not sure what's wrong
;-----------------------
LIST P=16F876
#include <p16F876.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ORG 0x2100
DE 0x00
ORG 0
cblock 0x20
d1
d2
d3
endc
goto start
Delay
;999990 cycles
movlw 0x07
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
;4 cycles (including call)
return
loop:
movlw b'00000111'
movwf PORTA
movlw b'11110010'
movwf PORTB
movlw b'11111111'
movwf PORTC
call Delay
call Delay
call Delay
goto loop
start:
bsf STATUS,RP0 ; select register page 1
movlw 0 ; put 0 into W
movwf TRISC ; set portC all output
clrf TRISA
clrf TRISB
bsf STATUS,RP1 ; select Page 2,
bcf STATUS,RP0 ; by setting RP1 in Status register and clearing RP0
clrf PORTC ; select Digital I/O on port C
bcf STATUS,RP1 ; back to Register Page 0
goto loop
end
;-----------------------
This program code is OK . But I want the program to which I could display the words fleeing across the screen. Started, I tried to ignite a pair of columns on different sites but with the burning LEDs. But received some strange flashing, do not light longer ... Anybody know what's wrong ...
Programme code:
;-----------------------
LIST P=16F876
#include <p16F876.inc>
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
ORG 0x2100
DE 0x00
ORG 0
cblock 0x20
Delay1 ; delay loop 1
Delay2 ; delay loop 2
Delay3 ; delay loop 3
TimeDelay ; time delay x 0.001 s
EndCount ; used to tell PIC the end of the table is reached
Counter ; used as table counter
Line1 ; Line 1
Line2 ; Line 2
Line3 ; Line 3
Line4 ; Line 4
Line5 ; Line 5
sad
Line6 ; Line 6
Line7 ; Line 7
Line8 ; Line 8
Layer4 ; brightness, and time
Brightness ; LED brightness
Time ; time for each pattern to stay
Temp ; temp register
d1
d2
d3
endc
goto start
Delay
;999990 cycles
movlw 0x17
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;6 cycles
goto $+1
goto $+1
goto $+1
;4 cycles (including call)
return
loop:
movlw b'00000001'
movwf Line1
movlw b'11110010'
movwf Line2
call output
call Delay
movlw b'11100000'
movwf Line1
movlw b'10101010'
movwf Line2
call output
call Delay
goto loop
start:
bsf STATUS,RP0 ; select register page 1
movlw 0 ; put 0 into W
movwf TRISC ; set portC all output
clrf TRISA
clrf TRISB
bsf STATUS,RP1 ; select Page 2,
bcf STATUS,RP0 ; by setting RP1 in Status register and clearing RP0
clrf PORTC ; select Digital I/O on port C
bcf STATUS,RP1 ; back to Register Page 0
goto loop
output:
movfw Layer4
andlw b'00000001'
movwf Time
incf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
bcf STATUS,C
rlf Time,1
clrf PORTB ; clear port B
movfw Line1 ; move layer1 to W
movwf PORTC ; put W onto PortC
bsf PORTB,4 ; turn on layer 1 buy outputing bit 5 of PortB
movfw Brightness ; put brightness into W
call Delayy ; call the delay
bcf PORTB,4 ; turn off layer 1
movfw Brightness ; put Brightness into W
sublw 4 ; sub W from 4
btfss STATUS,Z ; skip if the zero flag is set
call Delayy ; call the delay
decfsz Time
clrf PORTB ; clear port B
movfw Line2 ; move Line2 to W
movwf PORTC ; put W onto PortC
bsf PORTB,5 ; turn on layer 2 buy outputing bit 6 of PortB
movfw Brightness ; put brightness into W
call Delayy ; call the delay
bcf PORTB,5 ; turn off layer 2
movfw Brightness ; put Brightness into W
sublw 4 ; sub W from 4
btfss STATUS,Z ; skip if the zero flag is set
call Delayy ; call the delay
decfsz Time
decfsz Time ; decrement the Time regiester
return
Delayy:
movwf Delay3 ; put W into Delay 3
Loop1:
; After Delay2 decreses to 0, it is reset to..
movlw 0x1 ; put 1 into W
movwf Delay2 ; put W into Delay2
Loop2:
; After Delay1 decreses to 0, it is reset to E9h
movlw 0x1D ; put 80 into W
movwf Delay1 ; put W into Delay1
Loop3:
decfsz Delay1 ; decrement Delay1
goto Loop3 ; jump back to Loop3
decfsz Delay2 ; decrement Delay2
goto Loop2 ; jump back to Loop2
decfsz Delay3 ; decrement Delay3
goto Loop1 ; jump back to Loop1
return
end
;----------------------------------------------------------
Thanks for help.
REPLY
[flag][delete]
2
Jan 9, 2011. 7:48 AMhemmikarl (author) says:
A part of your problem might be the
Delayy:
that your subroutine is called but you call Delay on some parts of your code
The other part of your problem might be that you clear PORTB in the call of outputs
The code does not put PORTC all to 0 before it starts outputting so that might be a part of your problem
If it´s neither of those then I'm not sure what's wrong