PS7219 PIC microcontroller interface program

Publisher:uioo9158Latest update time:2019-10-22 Source: eefocusKeywords:PS7219 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

; Copyright (c) 1998, MICROCHIP Technology Inc 

;******************************************* 

TITLE "PS7219 TEST" ;Title 

LIST P=16C711 ;Processor is PIC16C711 microcontroller 

#INCLUDE P16c711.INC 

  

TIMER1 EQU H'000C' ;Define delay register 

TIMER2 EQU H'000D' 

SENT_ADDRESS EQU H'000E' ;Define send address register 

SENT_DATA EQU H'000F' ;Define send data register 

LED1 EQU H'0010' 

LED2 EQU H'0011' 

LED3 EQU H'0012' 

LED4 EQU H'0013' 

LED5 EQU H'0014' 

LED6 EQU H'0015' 

LED7 EQU H'0016' 

LED8 EQU H'0017' 

COUNT EQU H'0018' 

NO_OP EQU 0X00 ;Define control register 

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 ;Communication pin definition 

DOUT EQU 1 

CLK EQU 2 

  

ORG 0 

GOTO START ;Program start 

ORG H'0010' 

;**************************** 

; Delay subroutine 

;************************* 

T1 

MOVLW 33 ;Delay subroutine T1 

MOVWF TIMER1 

DEL_LOP 

CLRWDT 

DECFSZ TIMER1,1 

GOTO DEL_LOP 

RETURN 

  

T2 

MOVLW 0X04 ;Delay subroutine T2 

MOVWF TIMER1 

MOVLW 0XFF 

LOOP2 

MOVWF TIMER2 

LOOP1 

CLRWDT 

DECFSZ TIMER2,1 

GOTO LOOP1 

DECFSZ TIMER1,1 

GOTO LOOP2 

RETURN 

  

SEND 

MOVLW 8 ;Data transfer subroutine SEND 

MOVWF COUNT 

BCF PORTA,LOAD ;Initialize LOAD pin 

CALL T1 

SET_LP1 

BCF STATUS,C ;Send 8-bit address 

BSF PORTA,CLK 

RLF SENT_ADDRESS,1 

BCF PORTA,DOUT 

BTFSC STATUS,C 

BSF PORTA,DOUT 

BCF PORTA,CLK 

CALL T1 ;Call delay subroutine T1 

DECFSZ COUNT,1 ;When COUNT is reduced by one and becomes zero, the transfer ends 

GOTO SET_LP1 

BSF PORTA,CLK 

MOVLW 8 

MOVWF COUNT 

BSF PORTA,LOAD 

SET_LP2 

BCF STATUS,C ;Send 8-bit data 

BSF PORTA,CLK 

RLF SENT_DATA,1 

BCF PORTA,DOUT 

BTFSC STATUS,C 

BSF PORTA,DOUT 

BCF PORTA,CLK 

CALL T1 ;Call delay subroutine T1 

DECFSZ COUNT,1 ;When COUNT is reduced by one and becomes zero, the transfer ends 

GOTO SET_LP2 

BSF PORTA,CLK 

CALL T1 

BSF PORTA,LOAD 

BSF PORTA,DOUT 

RETURN ;The subroutine returns 

  

to START 

BSF STATUS,RP0 ; Main program 

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 ;Initialize PS7219 internal RAM 

MOVLW 0X0A ;Set the brightness to the brightest 

MOVWF SENT_ADDRESS 

MOVLW 0X0F 

MOVWF SENT_DATA 

CALL SEND ;Call serial communication subroutine 

CALL T1 

MOVLW 0X0B ;Set the scan boundary to 8 bits 

MOVWF SENT_ADDRESS 

MOVLW 0X07 

MOVWF SENT_DATA 

CALL SEND ;Call serial communication subroutine 

CALL T1 

MOVLW 0X09 ;Set each bit decoding mode to BCD decoding 

MOVWF SENT_ADDRESS 

MOVLW 0XFF 

MOVWF SENT_DATA 

CALL SEND 

CALL T1 

MOVLW 0X0C ;Set the working mode to normal 

MOVWF SENT_ADDRESS 

MOVLW 0X01 

MOVWF SENT_DATA 

CALL SEND 

  

LED_CON 

CALL T1 ;LED display control part 

MOVLW 0X01 ;LED1 displays 1 

MOVWF SENT_ADDRESS 

MOVLW 0X01 

MOVWF SENT_DATA 

CALL SEND 

CALL T1 

MOVLW 0X02 ;LED2 displays 2 

MOVWF SENT_ADDRESS 

MOVLW 0X02 

MOVWF SENT_DATA 

CALL SEND 

CALL T1 

MOVLW 0X03 ;LED3 displays 3 

MOVWF SENT_ADDRESS 

MOVLW 0X03 

MOVWF SENT_DATA 

CALL SEND 

CALL T1 

MOVLW 0X04 ;LED4 displays 4 

MOVWF SENT_ADDRESS 

MOVLW 0X04 

MOVWF SENT_DATA 

CALL SEND 

CALL T1 

MOVLW 0X05 ;LED5 displays as 5 

MOVWF SENT_ADDRESS 

MOVLW 0X05 

MOVWF SENT_DATA 

CALL SEND 

CALL T1 

MOVLW 0X06 ;LED6 displays as 6 

MOVWF SENT_ADDRESS 

MOVLW 0X06 

MOVWF SENT_DATA 

CALL SEND 

CALL T1 

MOVLW 0X07 ;LED7 displays as 7 

MOVWF SENT_ADDRESS 

MOVLW 0X07 

MOVWF SENT_DATA 

CALL SEND 

CALL T1 

MOVLW 0X08 ;LED8 displays as 8 

MOVWF SENT_ADDRESS 

MOVLW 0X08 

MOVWF SENT_DATA 

CALL SEND 

CALL T1 

  

MOVLW 0X0F ;Enter test mode 

MOVWF SENT_ADDRESS 

MOVLW 0X01 

MOVWF SENT_DATA 

CALL SEND 

CALL T1 

MOVLW 0X0F ;Exit test mode 

MOVWF SENT_ADDRESS 

MOVLW 0X00 

MOVWF SENT_DATA 

CALL SEND 

CALL T1 

MOVLW 0X0D ;Enable 8-bit LED flashing 

MOVWF SENT_ADDRESS 

MOVLW 0XFF 

MOVWF SENT_DATA 

CALL SEND 

FINISH CLRWDT ;Clear Watch Dog 

GOTO FINISH 

END ;End   


Keywords:PS7219 Reference address:PS7219 PIC microcontroller interface program

Previous article:Example program to read and write 1-wire EEPROM DS2430 using PIC microcontroller
Next article:Problems and Countermeasures in Application of PIC16C71/PIC16C84 Microcontroller

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号