📄 led_4disp.asm
字号:
;==================================================================================
; The information contained herein is the exclusive property of
; Sunplus Technology Co. And shall not be distributed, reproduced,
; or disclosed in whole in part without prior written permission.
; (C) COPYRIGHT 2004 SUNPLUS TECHNOLOGY CO.
; ALL RIGHTS RESERVED
; The entire notice above must be reproduced on all authorized copies.
;==================================================================================
;==================================================================================
; Program Name : LED_4Disp.asm
; Description : 7-segment LEDs display
; Reference : SPMC65P2404A/2408A Data Sheet
; Revision history :
;----------------------------------------------------------------------------------
; Version Date Description
; 1.0.0 2004-10-22 First Edition
;==================================================================================
.SYNTAX 6502 ;Process standard 6502 addressing syntax
.LINKLIST ;Generate linklist information
.SYMBOLS ;Generate symbolic debug information
;************************************************************************************
;************************************************************************************
.PAGE0
GB_ShowBuf DS 4 ;Define a four byte area
GB_IndexCom DS 1 ;The value controll the showing order of LEDs
.DATA
;************************************************************************************
.CODE
;====================================================================================
; Function: F_LED_4Disp
; Description: Show the datas saved in a four_byte area inducted by [GB_ShowBuf]
; Input: Four-byte showing datas
; Output: none
; Destroy: A,X
; Stacks: none
;====================================================================================
F_LED_4Disp:
ldx GB_IndexCom
inx ;LED com ++
cpx #4 ;LED com scanning over ?
beq ?L_ClearX ;Yes
stx GB_IndexCom
jmp ?L_Show
?L_ClearX:
ldx #$00
stx GB_IndexCom ;Showing from the first LED
?L_Show:
lda #$00
sta P_IOA_Data ;Clear the screen
lda P_IOC_Buf
and #%11110000 ;\ Reach the new common word
ora T_SevenComTable,x ;/
sta P_IOC_Data ;Move common word to PD
lda GB_ShowBuf,x ;Reach the data from showing buffer
tax
lda T_SevenSegTable,x ;Get the segment
; eor #$FF
sta P_IOA_Data ;Move the segment word to PC
?L_Div_End:
rts
;====================================================================================
; Function: F_IO_Init
; Description: initialize I/O Port PA(bit0~bit7) PC(bit0~bit3) as output with pull low
; Input: none
; Output: none
; Destroy: A
; Stacks: none
;====================================================================================
F_IO_Init:
lda #$00 ;\
sta P_IOA_Data ;+
lda #%00000000 ;+ = Inite Port A output "0"
sta P_IOA_Attrib ;+
lda #%11111111 ;+
sta P_IOA_Dir ;/
lda P_IOC_Data ;\
and #%11110000 ;+
sta P_IOC_Data ;+
lda P_IOC_Attrib ;+
and #%11110000 ;+ = Inite Port C output "0"
sta P_IOC_Attrib ;+
lda P_IOC_Dir ;+
ora #%00001111 ;+
sta P_IOC_Dir ;/
rts
;====================================================================================
; Function: F_Tim0_Init
; Description: Set 4ms interrupt in timer0
; Input: none
; Output: none
; Destroy: A
; Stacks: none
;====================================================================================
F_Timer2_Init:
lda #C_T2FCS_Div_512 ;8000000/512/32=488Hz=2048us
sta P_TMR2_3_Ctrl1
lda #224
sta P_TMR2_Preload
lda #C_T28B_Timer
sta P_TMR2_3_Ctrl0
lda #$FF
sta P_INT_Flag0 ;Clear INT request flag
sta P_INT_Flag1
sta P_INT_Flag2
rts
;************************************************************************************
;* *
;* The Com and Segment Table of LED *
;* *
;************************************************************************************
T_SevenComTable: ;The com table of led
DB %00000001 ;LED '1'
DB %00000010 ;LED '2'
DB %00000100 ;LED '3'
DB %00001000 ;LED '4'
T_SevenSegTable: ;The segment table of led
DB %00111111 ;Character '0'
DB %00000110 ;Character '1'
DB %01011011 ;Character '2'
DB %01001111 ;Character '3'
DB %01100110 ;Character '4'
DB %01101101 ;Character '5'
DB %01111101 ;Character '6'
DB %00000111 ;Character '7'
DB %01111111 ;Character '8'
DB %01101111 ;Character '9'
DB %01110111 ;Character 'A'
DB %01111100 ;Character 'b'
DB %00111001 ;Character 'C'
DB %01011110 ;Character 'd'
DB %01111001 ;Character 'E'
DB %01110001 ;Character 'F'
DB %01000000 ;Character '-'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -