とりあえず英文字表示仕様のソースです。皆さんでどんどん改造してみて下さい。;**********************************************************************
; Filename: matrix2.asm *
; Date: 2001/4/25 *
; File Version: *
;**********************************************************************
list p=16F84 ; list directive to define processor
#include <p16F84.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
;***** VARIABLE DEFINITIONS
w_temp EQU 0x0C ; variable used for context saving
status_temp EQU 0x0D ; variable used for context saving
wait_data EQU 0x10 ;wait data
count_sub EQU 0x11 ;count sub data
count_sub2 EQU 0x12 ;count sub2 data
taihi EQU 0x13 ;taihi data
auto_mode EQU 0x14 ;auto mode ram
;auto_mode,0 auto/stop select
count_data EQU 0x15 ;0.5sec keisoku count ram
led_data0 EQU 0x20 ;LED DATA(0)
led_data1 EQU 0x21 ;LED DATA(1)
led_data2 EQU 0x22 ;LED DATA(2)
led_data3 EQU 0x23 ;LED DATA(3)
led_data4 EQU 0x24 ;LED DATA(4)
led_data5 EQU 0x25 ;LED DATA(5)
led_data6 EQU 0x26 ;LED DATA(6)
led_data7 EQU 0x27 ;LED DATA(7)
tm0_setdata EQU 63h ;255-156=99=63H 156*128=19.968msec
cnt_setdata EQU 19h ;19.968*25=0.4992sec
;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
;----------------------------------------------------------------------------------
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
;---------------------------------
bcf INTCON,T0IF
movlw tm0_setdata
movwf TMR0
decfsz count_data,1
goto int_end
time_up movlw cnt_setdata
movwf count_data
;--------------------------------
btfss auto_mode,0
goto int_end
incf count_sub,1
decfsz count_sub2,1
goto int_next2
call count_init
;--------------------------------
int_next2 call led_set_sub
int_end
;----------------------------------
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
;---------------------------------------------------------------------------------------
main
call port_set
movlw 00h ;port initial set
movwf PORTA
movlw 0ffh
movwf PORTB
call count_init
call led_set_sub
movlw 01h
movwf auto_mode
call timer0_set
movlw cnt_setdata
movwf count_data
main_loop
;-------------------------------------- key scan
sw1_key btfsc PORTA,3
goto next_key
call wait_1
btfsc PORTA,3
goto next_key
;sw1 on
btfsc auto_mode,0
goto sw1_key2
bsf auto_mode,0 ;mode auto
goto sw1_end
sw1_key2 bcf auto_mode,0 ;mode stop
sw1_end btfss PORTA,3
goto sw1_end
next_key
;-------------------------------------- led disp
movlw 00h
movwf PORTA
movf led_data0,0
movwf PORTB
call wait_1
movlw 01h
movwf PORTA
movf led_data1,0
movwf PORTB
call wait_1
movlw 02h
movwf PORTA
movf led_data2,0
movwf PORTB
call wait_1
movlw 03h
movwf PORTA
movf led_data3,0
movwf PORTB
call wait_1
movlw 04h
movwf PORTA
movf led_data4,0
movwf PORTB
call wait_1
movlw 05h
movwf PORTA
movf led_data5,0
movwf PORTB
call wait_1
movlw 06h
movwf PORTA
movf led_data6,0
movwf PORTB
call wait_1
movlw 07h
movwf PORTA
movf led_data7,0
movwf PORTB
call wait_1
;---------------------------------------
main_next
goto main_loop
;-------------------------------------------------------------------------------
led_set_sub movf count_sub,0
call led_data_line0
movwf led_data0
movf count_sub,0
call led_data_line1
movwf led_data1
movf count_sub,0
call led_data_line2
movwf led_data2
movf count_sub,0
call led_data_line3
movwf led_data3
movf count_sub,0
call led_data_line4
movwf led_data4
movf count_sub,0
call led_data_line5
movwf led_data5
movf count_sub,0
call led_data_line6
movwf led_data6
movf count_sub,0
call led_data_line7
movwf led_data7
return
;-------------------------------------------------------------------------------
count_init movlw 00h
movwf count_sub
movlw 1ah ;count su
movwf count_sub2
return
;-------------------------------------------------------------------------------
led_data_line0 movwf taihi
movlw low(table0)
addwf taihi,1
movlw high(table0)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
table0 retlw 03h ;A
retlw 00h ;B
retlw 81h ;C
retlw 00h ;D
retlw 00h ;E
retlw 00h ;F
retlw 81h ;G
retlw 00h ;H
retlw 0ffh ;I
retlw 9fh ;J
retlw 00h ;K
retlw 00h ;L
retlw 00h ;M
retlw 00h ;N
retlw 81h ;O
retlw 00h ;P
retlw 81h ;Q
retlw 00h ;R
retlw 0b9h ;S
retlw 0feh ;T
retlw 80h ;U
retlw 0f8h ;V
retlw 80h ;W
retlw 3ch ;X
retlw 0f8 ;Y
retlw 3eh ;Z
;-------------------------------------------------------------------------------
led_data_line1 movwf taihi
movlw low(table1)
addwf taihi,1
movlw high(table1)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
table1 retlw 01h ;A
retlw 00h ;B
retlw 00h ;C
retlw 00h ;D
retlw 00h ;E
retlw 00h ;F
retlw 00h ;G
retlw 00h ;H
retlw 0ffh ;I
retlw 1fh ;J
retlw 00h ;K
retlw 00h ;L
retlw 00h ;M
retlw 00h ;N
retlw 00h ;O
retlw 00h ;P
retlw 00h ;Q
retlw 00h ;R
retlw 30h ;S
retlw 0feh ;T
retlw 00h ;U
retlw 0e0h ;V
retlw 00h ;W
retlw 18h ;X
retlw 0f0h ;Y
retlw 1eh ;Z
;-------------------------------------------------------------------------------
led_data_line2 movwf taihi
movlw low(table2)
addwf taihi,1
movlw high(table2)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
table2 retlw 0cch ;A
retlw 66h ;B
retlw 3ch ;C
retlw 7eh ;D
retlw 66h ;E
retlw 0e6h ;F
retlw 3ch ;G
retlw 0e7h ;H
retlw 7eh ;I
retlw 3fh ;J
retlw 0e7h ;K
retlw 7fh ;L
retlw 0f9h ;M
retlw 0f1h ;N
retlw 3ch ;O
retlw 0e6h ;P
retlw 3ch ;Q
retlw 0e6h ;R
retlw 60h ;S
retlw 0feh ;T
retlw 3fh ;U
retlw 83h ;V
retlw 1fh ;W
retlw 81h ;X
retlw 0e3h ;Y
retlw 0eh ;Z
;-------------------------------------------------------------------------------
led_data_line3 movwf taihi
movlw low(table3)
addwf taihi,1
movlw high(table3)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
table3 retlw 0cch ;A
retlw 66h ;B
retlw 7eh ;C
retlw 7eh ;D
retlw 66h ;E
retlw 0e6h ;F
retlw 7eh ;G
retlw 0e7h ;H
retlw 00h ;I
retlw 7fh ;J
retlw 0c3h ;K
retlw 7fh ;L
retlw 0e3h ;M
retlw 0e3h ;N
retlw 7eh ;O
retlw 0e6h ;P
retlw 7eh ;Q
retlw 0c6h ;R
retlw 66h ;S
retlw 00h ;T
retlw 7fh ;U
retlw 0fh ;V
retlw 83h ;W
retlw 0c3h ;X
retlw 07h ;Y
retlw 46h ;Z
;-------------------------------------------------------------------------------
led_data_line4 movwf taihi
movlw low(table4)
addwf taihi,1
movlw high(table4)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
table4 retlw 0cch ;A
retlw 66h ;B
retlw 7eh ;C
retlw 7eh ;D
retlw 66h ;E
retlw 0e6h ;F
retlw 66h ;G
retlw 0e7h ;H
retlw 00h ;I
retlw 7eh ;J
retlw 81h ;K
retlw 7fh ;L
retlw 0e3h ;M
retlw 0c7h ;N
retlw 7eh ;O
retlw 0e6h ;P
retlw 4eh ;Q
retlw 86h ;R
retlw 66h ;S
retlw 00h ;T
retlw 7fh ;U
retlw 0fh ;V
retlw 83h ;W
retlw 0c3h ;X
retlw 07h ;Y
retlw 62h ;Z
;-------------------------------------------------------------------------------
led_data_line5 movwf taihi
movlw low(table5)
addwf taihi,1
movlw high(table5)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
table5 retlw 0cch ;A
retlw 00h ;B
retlw 3ch ;C
retlw 3ch ;D
retlw 66h ;E
retlw 0e6h ;F
retlw 24h ;G
retlw 0e7h ;H
retlw 7eh ;I
retlw 3eh ;J
retlw 18h ;K
retlw 7fh ;L
retlw 0f9h ;M
retlw 8fh ;N
retlw 3ch ;O
retlw 0e6h ;P
retlw 1ch ;Q
retlw 06h ;R
retlw 06h ;S
retlw 0feh ;T
retlw 3fh ;U
retlw 83h ;V
retlw 1fh ;W
retlw 81h ;X
retlw 0e3h ;Y
retlw 70h ;Z
;-------------------------------------------------------------------------------
led_data_line6 movwf taihi
movlw low(table6)
addwf taihi,1
movlw high(table6)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
table6 retlw 01h ;A
retlw 00h ;B
retlw 18h ;C
retlw 00h ;D
retlw 66h ;E
retlw 0e6h ;F
retlw 04h ;G
retlw 00h ;H
retlw 0ffh ;I
retlw 00h ;J
retlw 3ch ;K
retlw 7fh ;L
retlw 00h ;M
retlw 00h ;N
retlw 00h ;O
retlw 0e0h ;P
retlw 00h ;Q
retlw 20h ;R
retlw 0ch ;S
retlw 0feh ;T
retlw 00h ;U
retlw 0e0h ;V
retlw 00h ;W
retlw 18h ;X
retlw 0f0h ;Y
retlw 78h ;Z
;-------------------------------------------------------------------------------
led_data_line7 movwf taihi
movlw low(table7)
addwf taihi,1
movlw high(table7)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
table7 retlw 03h ;A
retlw 99h ;B
retlw 99h ;C
retlw 81h ;D
retlw 7eh ;E
retlw 0feh ;F
retlw 8dh ;G
retlw 00h ;H
retlw 0ffh ;I
retlw 80h ;J
retlw 7eh ;K
retlw 7fh ;L
retlw 00h ;M
retlw 00h ;N
retlw 81h ;O
retlw 0f1h ;P
retlw 81h ;Q
retlw 71h ;R
retlw 9dh ;S
retlw 0feh ;T
retlw 80h ;U
retlw 0f8h ;V
retlw 80h ;W
retlw 3ch ;X
retlw 0f8h ;Y
retlw 7ch ;Z
;-------------------------------------------------------------------------------
wait_1
movlw 0ffh
movwf wait_data
wait_2
decfsz wait_data,1
goto wait_2
return
;-------------------------------------------------------------------------------
port_set ;RA0,RA1,RA2,RA4(OUT)
;RA3(IN)
;RB0,RB1,RB2,RB3,RB4,RB5,RB6,RB7(OUT)
bsf STATUS,RP0
clrf TRISA
bsf TRISA,3
nop
clrf TRISB
bcf STATUS,RP0
return
;-------------------------------------------------------------------------------
timer0_set
bsf STATUS,RP0
movlw 086h ;(1)PORTB NOT PULLUP
;(0)INTEDG
;(0)TOCS
;(0)TOSE
;(0)PSA
;(110)1/128
movwf OPTION_REG
bcf STATUS,RP0
movlw tm0_setdata
movwf TMR0
bsf INTCON,T0IE
bsf INTCON,GIE
return
;-----------------------------------------------------------------------------
END ; directive 'end of program'
|