MessUpMymind
New Member
HI there,
I am currently working on LED dot matrix display by using 16F877A and 74LS164 shift register to shift the data that out from 877A..I face a few problem while doing the shifting..
1) LED Dot Matrix only keep showing the first data that i sent in but the following data doesn't not show up on the display.
2)First data that i sent in , light on all the time and there's no shifting that can be seen on the matrix display.
The above is the code that i put into the micro-controller , i compile with MPLAB and it doesn't show any error occur..
can any1 please give me a way how to correct it , any suggestion is most welcome ??
I am currently working on LED dot matrix display by using 16F877A and 74LS164 shift register to shift the data that out from 877A..I face a few problem while doing the shifting..
1) LED Dot Matrix only keep showing the first data that i sent in but the following data doesn't not show up on the display.
2)First data that i sent in , light on all the time and there's no shifting that can be seen on the matrix display.
Code:
#include "P16f877a.inc"
__CONFIG 0x399A
cblock 0x20
d1
d2
d3
endc
shift_count equ .5
ORG 0x00
BSF STATUS,5 ; set bit 5 of STATUS to change to bank 1
BANKSEL TRISD
BANKSEL TRISC
MOVLW 0x00 ; clear TRISB to change PORTB as output
MOVWF TRISD
MOVLW 0x00 ; clear TRISD to change PORTC as output
MOVWF TRISC
BCF STATUS,5
BANKSEL PORTD
BANKSEL PORTC
clrf PORTD
clrf PORTC
BCF PORTC,2 ; set shift register clear pin
BSF PORTC,2 ; clear shift register clear pin
MOVLW 0A8h
MOVWF 11h
MOVLW 80h
MOVWF 12h
MOVLW 23h
MOVWF 13h
MOVLW 55h
MOVWF 14h
MOVLW 00h
MOVWF 15h
Shift1: BSF PORTC,1 ;74LS164 data pin set to high
MOVF 11h,0 ;first data 0A8h come in
MOVWF PORTD ; move data to output PORTD
CALL CLK ; call clock to move the data to collumns
BCF PORTC,1 ;74LS164 data pin set to low
CLRF PORTD ;clear the first data (0A8h)
CALL Delay ;call delay
DECFSZ shift_count,1 ; Shift for 5 times and jump to second data
GOTO Shift1 ;if not continue count
GOTO Shift2
Shift2: MOVF 12h,0 ;second data 80h
MOVWF PORTD ;move data to output PORTD
BCF PORTC,1
CALL CLK
CLRF PORTD
CALL Delay
DECFSZ shift_count,1
GOTO Shift2
GOTO Shift3
Shift3: MOVF 13h,0
MOVWF PORTD
CALL CLK
CLRF PORTD
CALL Delay
DECFSZ shift_count,1
GOTO Shift3
GOTO Shift4
Shift4: MOVF 14h,0
MOVWF PORTD
CALL CLK
CLRF PORTD
CALL Delay
DECFSZ shift_count,1
GOTO Shift4
GOTO Shift5
Shift5: MOVF 15h,0
MOVWF PORTD
CALL CLK
CLRF PORTD
GOTO Delay
DECFSZ shift_count,1
GOTO Shift5
GOTO Shift1
Delay:
;499994 cycles
movlw 0x03
movwf d1
movlw 0x18
movwf d2
movlw 0x02
movwf d3
Delay_0:
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;2 cycles
goto $+1
;4 cycles (including call)
return
CLK: BCF PORTC,0 ;send in clock pulse
BSF PORTC,0 ;at PORTC, pin 0
call Delay ;Call Delay to make the character viewable.
return
END
The above is the code that i put into the micro-controller , i compile with MPLAB and it doesn't show any error occur..
can any1 please give me a way how to correct it , any suggestion is most welcome ??