, PS7219的PIC单片机接口程序 ; ; Copyright (c) 1998, MICROCHIP Technology Inc ; P&S Proprietary and Confidential ; ; SCCSID @(#)TEST711.asm 1.0 9/28/98 ; ; Author : CHUNRI FENG ; Filename : TEST711.ASM ; Release : 1.0 ; Revision History : ; Created SEP-28,98 ; ;--------------------------------------------------------------------------- - ;************************************************* TITLE "PS7219 TEST" ;标题 LIST P=16C711 ;处理器为PIC16C711 #INCLUDE P16c711.INC
TIMER1 EQU H000C ;定义延时寄存器 TIMER2 EQU H000D SENT_ADDRESS EQU H000E ;定义发送地址寄存器 SENT_DATA EQU H000F ;定义发送数据寄存器 LED1 EQU H0010 LED2 EQU H0011 LED3 EQU H0012 LED4 EQU H0013 LED5 EQU H0014 LED6 EQU H0015 LED7 EQU H0016 LED8 EQU H0017 COUNT EQU H0018 NO_OP EQU 0X00 ;定义控制寄存器 DIGIT1 EQU 0X01 DIGIT2 EQU 0X02 DIGIT3 EQU 0X03 DIGIT4 EQU 0X04 DIGIT5 EQU 0X05 DIGIT6 EQU 0X06 DIGIT7 EQU 0X07 DIGIT8 EQU 0X08 DECODE EQU 0X09 INTSEN EQU 0X0A SCAN EQU 0X0B SHUT EQU 0X0C FLASH EQU 0X0D DISPLAY EQU 0X0F
LOAD EQU 0 ;通讯引脚定义 DOUT EQU 1 CLK EQU 2
ORG 0 GOTO START ;程序开始 ORG H0010 ;************************* ; 延时子程序 ;************************* T1 MOVLW 33 ;延时子程序T1 MOVWF TIMER1 DEL_LOP CLRWDT DECFSZ TIMER1,1 GOTO DEL_LOP RETURN
T2 MOVLW 0X04 ;延时子程序T2 MOVWF TIMER1 MOVLW 0XFF LOOP2 MOVWF TIMER2 LOOP1 CLRWDT DECFSZ TIMER2,1 GOTO LOOP1 DECFSZ TIMER1,1 GOTO LOOP2 RETURN
SEND MOVLW 8 ;数据传送子程序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 MOVLW 8 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 ;主程序 MOVLW 0X18 MOVWF TRISA MOVLW 0XFF MOVWF TRISB BCF STATUS,RP0 CALL T1 CALL T1 MOVLW 0X12 MOVWF PORTA BCF PORTA,LOAD CON_COM CALL T1 ;初始化PS7219内部RAM MOVLW 0X0A ;设置亮度为最亮 MOVWF SENT_ADDRESS MOVLW 0X0F MOVWF SENT_DATA CALL SEND ;调用串行通讯子程序 CALL T1 MOVLW 0X0B ;设置扫描界线为8位 MOVWF SENT_ADDRESS MOVLW 0X07 MOVWF SENT_DATA CALL SEND ;调用串行通讯子程序 CALL T1 MOVLW 0X09 ;设置每位译码方式为BCD译码 MOVWF SENT_ADDRESS MOVLW 0XFF MOVWF SENT_DATA CALL SEND CALL T1 MOVLW 0X0C ;设置工作方式为正常 MOVWF SENT_ADDRESS MOVLW 0X01 MOVWF SENT_DATA CALL SEND
LED_CON CALL T1 ;LED显示控制部分 MOVLW 0X01 ;LED1显示为1 MOVWF SENT_ADDRESS MOVLW 0X01 MOVWF SENT_DATA CALL SEND CALL T1 MOVLW 0X02 ;LED2显示为2 MOVWF SENT_ADDRESS MOVLW 0X02 MOVWF SENT_DATA CALL SEND CALL T1 MOVLW 0X03 ;LED3显示为3 MOVWF SENT_ADDRESS MOVLW 0X03 MOVWF SENT_DATA CALL SEND CALL T1 MOVLW 0X04 ;LED4显示为4 MOVWF SENT_ADDRESS MOVLW 0X04 MOVWF SENT_DATA CALL SEND CALL T1 MOVLW 0X05 ;LED5显示为5 MOVWF SENT_ADDRESS MOVLW 0X05 MOVWF SENT_DATA CALL SEND CALL T1 MOVLW 0X06 ;LED6显示为6 MOVWF SENT_ADDRESS MOVLW 0X06 MOVWF SENT_DATA CALL SEND CALL T1 MOVLW 0X07 ;LED7显示为7 MOVWF SENT_ADDRESS MOVLW 0X07 MOVWF SENT_DATA CALL SEND CALL T1 MOVLW 0X08 ;LED8显示为8 MOVWF SENT_ADDRESS MOVLW 0X08 MOVWF SENT_DATA CALL SEND CALL T1
MOVLW 0X0F ;进入测试模式 MOVWF SENT_ADDRESS MOVLW 0X01 MOVWF SENT_DATA CALL SEND CALL T1 MOVLW 0X0F ;退出测试模式 MOVWF SENT_ADDRESS MOVLW 0X00 MOVWF SENT_DATA CALL SEND CALL T1 MOVLW 0X0D ;使能8位LED闪烁 MOVWF SENT_ADDRESS MOVLW 0XFF MOVWF SENT_DATA CALL SEND FINISH CLRWDT ;清Watch Dog GOTO FINISH
END ;结束
|