Professional Documents
Culture Documents
lab6 thí nghiệm VLX quét led ma trận
lab6 thí nghiệm VLX quét led ma trận
HCM
TRNG I HC BCH KHOA
KHOA KHOA HC V K THUT MY TNH
BO CO TH NGHIM
VI X L - VI IU KHIN
LAB 6 QUT LED MA TRN VK PIC 18F8722
1. C S L Thuyt:
Led Ma Trn 8x8:
Bit Xanh
Bit
Mu
en
Xanh
Cam
list p = PIC18f8722
#include p18f8722.inc
#define SO_DEM_10MS .2500
#define RCOL
LATD
#define GCOL
LATC
#define ROW
LATB
code 0
goto
start
org
0x08
goto
isr_high
org
0x18
goto
isr_low
udata
PRG
code 0x30
start
call
init
main
movw
0xC3
3
movwf
movw
movwf
movw
movwf
bra
RCOL
0x99
GCOL
0x01
ROW
main
init
clrf RCOL
clrf GCOL
clrf ROW
movlw H'0F'
movwf ADCON1
end
4.Xut d liu ra nhiu hng
-Dng timer chuyn hng
Hnh yu cu
list p = PIC18f8722
#include p18f8722.inc
#define SO_DEM_10MS .2500
#define RCOL LATD
#define GCOL LATC
#define ROW LATB
4
code 0
goto
start
org
goto
0x08
isr_high
org
0x18
goto
isr_low
tam
res
.1
rbuf
res
.8
gbuf
res
.8
index
res
.1
hang
res
.1
PRG
code
0x30
start
call init
udata
call timer0_init
main
bra main
timer0_init
bsf
RCON, IPEN
bcf
INTCON2,TMR0IP
bcf
INTCON,TMR0IF
bsf
INTCON,TMR0IE
bsf
INTCON,GIEH
bsf
INTCON,GIEL
clrf
T0CON
movlw HIGH(-SO_DEM_10MS)
5
movwf TMR0H
movlw LOW(-SO_DEM_10MS)
movwf TMR0L
bsf
T0CON,TMR0ON
return
timer0_isr
bcf
INTCON,TMR0IF
bcf
T0CON,TMR0ON
movlw HIGH(-SO_DEM_10MS)
movwf TMR0H
movlw LOW(-SO_DEM_10MS)
movwf TMR0L
bsf
T0CON,TMR0ON
RCALL xuly
return
xuly
clrf
ROW
;lfsr
FSR1, rbuf
;lfsr
FSR2, gbuf
movf
index, W
movff tam,RCOL
movf
index, W
movf
hang, W
movwf ROW
rrncf
hang
incf
index
movlw .8
cpfslt
index
clrf
index
return
isr_high retfie
isr_low
rcall
timer0_isr
retfie
init
clrf
LATB
clrf
TRISC
clrf
TRISD
clrf
TRISB
clrf
index
movlw 0x01
movwf hang
clrf
RCOL
clrf
GCOL
7
movlw H'0F'
movwf ADCON1
movlw 0x01
movwf rbuf
movlw 0x02
movwf rbuf+.1
movlw 0x04
movwf rbuf+.2
movlw 0x18
movwf rbuf+.3
movlw 0x18
movwf rbuf+.4
movlw 0x20
movwf rbuf+.5
movlw 0x40
movwf rbuf+.6
movlw 0x80
movwf rbuf+.7
movlw 0x80
movwf gbuf
movlw 0x40
movwf gbuf+.1
movlw 0x20
movwf gbuf+.2
movlw 0x18
8
movwf gbuf+.3
movlw 0x18
movwf gbuf+.4
movlw 0x04
movwf gbuf+.5
movlw 0x02
movwf gbuf+.6
movlw 0x01
movwf gbuf+.7
return
end
3.Tng kt:
- Kho st cc hot ng ca LED Ma trn tun t xut nhp x l xut d liu ra led,qut LED.
- Cch tnh ton v thit lp cc gi tr trong bng RAM,ROM cho ng yu cu.
- Bit cch thc thi v sa li, cc cng c sa li c p dng khi lp trnh.