;Copyright (c)1998,MICROChip Technology Inc
;*************************************************
TITLE"PS7219TEST";标题
LIST P=16C711;处理器为PIC16C711
#INCLUDE P16c711.INC
TIMER1EQU H'000C';定义延时寄存器
TIMER2EQU H'000D'
SENT_ADDRESS EQU H'000E';定义发送地址寄存器
SENT_DATA EQU H'000F';定义发送数据寄存器
LED1EQU H'0010'
LED2EQU H'0011'
LED3EQU H'0012'
LED4EQU H'0013'
LED5EQU H'0014'
LED6EQU H'0015'
LED7EQU H'0016'
LED8EQU H'0017'
COUNT EQU H'0018'
NO_OP EQU0X00;定义控制寄存器
DIGIT1EQU0X01
DIGIT2EQU0X02
DIGIT3EQU0X03
DIGIT4EQU0X04
DIGIT5EQU0X05
DIGIT6EQU0X06
DIGIT7EQU0X07
DIGIT8EQU0X08
DECODE EQU0X09
INTSEN EQU0X0A
SCAN EQU0X0B
SHUT EQU0X0C
FLASH EQU0X0D
DISPLAY EQU0X0F
LOAD EQU0;通讯引脚定义
DOUT EQU1
CLK EQU2
ORG0
GOTO START;程序开始
ORG H'0010'
;*************************
;延时子程序
;*************************
T1
MOVLW33;延时子程序T1
MOVWF TIMER1
DEL_LOP
CLRWDT
DECFSZ TIMER1,1
GOTO DEL_LOP
RETURN
T2
MOVLW0X04;延时子程序T2
MOVWF TIMER1
MOVLW0XFF
LOOP2
MOVWF TIMER2
LOOP1
CLRWDT
DECFSZ TIMER2,1
GOTO LOOP1
DECFSZ TIMER1,1
GOTO LOOP2
RETURN
SEND
MOVLW8;数据传送子程序SEND
MOVWF COUNT
BCF PORTA,LOAD;初始化LOAD引脚
CALL T1
SET_LP1
BCF STATUS,C;发送8位地址
BSF PORTA,CLK
RLF SENT_ADDRESS,1
BCF PORTA,DOUT
BTFSC STATUS,C
BSF PORTA,DOUT
BCF PORTA,CLK
CALL T1;调用延时子程序T1
DECFSZ COUNT,1;COUNT减一为1零则结束传送
GOTO SET_LP1
BSF PORTA,CLK
MOVLW8
MOVWF COUNT
BSF PORTA,LOAD
SET_LP2
BCF STATUS,C;发送8位数据
BSF PORTA,CLK
RLF SENT_DATA,1
BCF PORTA,DOUT
BTFSC STATUS,C
BSF PORTA,DOUT
BCF PORTA,CLK
CALL T1;调用延时子程序T1
DECFSZ COUNT,1;COUNT减一为零则结束传送
GOTO SET_LP2
BSF PORTA,CLK
CALL T1
BSF PORTA,LOAD
BSF PORTA,DOUT
RETURN;子程序返回
START
BSF STATUS,RP0;主程序
MOVLW0X18
MOVWF TRISA
MOVLW0XFF
MOVWF TRISB
BCF STATUS,RP0
CALL T1
CALL T1
MOVLW0X12
MOVWF PORTA
BCF PORTA,LOAD
CON_COM
CALL T1;初始化PS7219内部RAM
MOVLW0X0A;设置亮度为最亮
MOVWF SENT_ADDRESS
MOVLW0X0F
MOVWF SENT_DATA
CALL SEND;调用串行通讯子程序
CALL T1
MOVLW0X0B;设置扫描界线为8位
MOVWF SENT_ADDRESS
MOVLW0X07
MOVWF SENT_DATA
CALL SEND;调用串行通讯子程序
CALL T1
MOVLW0X09;设置每位译码方式为BCD译码
MOVWF SENT_ADDRESS
MOVLW0XFF
MOVWF SENT_DATA
CALL SEND
CALL T1
MOVLW0X0C;设置工作方式为正常
MOVWF SENT_ADDRESS
MOVLW0X01
MOVWF SENT_DATA
CALL SEND
LED_CON
CALL T1;LED显示控制部分
MOVLW0X01;LED1显示为1
MOVWF SENT_ADDRESS
MOVLW0X01
MOVWF SENT_DATA
CALL SEND
CALL T1
MOVLW0X02;LED2显示为2
MOVWF SENT_ADDRESS
MOVLW0X02
MOVWF SENT_DATA
CALL SEND
CALL T1
MOVLW0X03;LED3显示为3
MOVWF SENT_ADDRESS
MOVLW0X03
MOVWF SENT_DATA
CALL SEND
CALL T1
MOVLW0X04;LED4显示为4
MOVWF SENT_ADDRESS
MOVLW0X04
MOVWF SENT_DATA
CALL SEND
CALL T1
MOVLW0X05;LED5显示为5
MOVWF SENT_ADDRESS
MOVLW0X05
MOVWF SENT_DATA
CALL SEND
CALL T1
MOVLW0X06;LED6显示为6
MOVWF SENT_ADDRESS
MOVLW0X06
MOVWF SENT_DATA
CALL SEND
CALL T1
MOVLW0X07;LED7显示为7
MOVWF SENT_ADDRESS
MOVLW0X07
MOVWF SENT_DATA
CALL SEND
CALL T1
MOVLW0X08;LED8显示为8
MOVWF SENT_ADDRESS
MOVLW0X08
MOVWF SENT_DATA
CALL SEND
CALL T1
MOVLW0X0F;进入测试模式
MOVWF SENT_ADDRESS
MOVLW0X01
MOVWF SENT_DATA
CALL SEND
CALL T1
MOVLW0X0F;退出测试模式
MOVWF SENT_ADDRESS
MOVLW0X00
MOVWF SENT_DATA
CALL SEND
CALL T1
MOVLW0X0D;使能8位LED闪烁
MOVWF SENT_ADDRESS
MOVLW0XFF
MOVWF SENT_DATA
CALL SEND
FINISH CLRWDT;清Watch Dog
GOTO FINISH
END;结束