硬件方面:
pic通过74hc595来位选数码管.ra0口接595的rclk,ra1口接595的srclk,ra2口接595的ser
pic的d口输出字型码.
软件方面:
list p=16f877 include"p16f877.inc" count equ 34h bits equ 35h inter equ 36h count1 equ 37h bits1 equ 38h org 0x00 nop initial ;初始化 banksel TRISA movlw 0x00 movwf TRISA movwf TRISD banksel PORTD movlw 0x00 movwf PORTD clrf count clrf bits clrf inter movlw 00h movwf bits movlw 08h movwf count bcf PORTA,0 noop bcf PORTA,1 movf PORTA,W andlw 0xfb iorwf bits,w movwf PORTA bsf PORTA,1 rlf bits,1 decfsz count goto noop bsf PORTA,0
main movlw 0x99 movwf PORTD ;段型码送d口 movlw 04h movwf count1
movlw 08h movwf bits ;位选信号放在bits寄存器中 movwf bits1 ;位选信号送中间寄存器 loop1 movlw 04h ;下面一段程序为串并转换 movwf count tab rlf bits,1 decfsz count,1 goto tab movlw 08h movwf count bcf PORTA,0 ;为送锁存信号做准备 loop bcf PORTA,1 ;为送时钟信号做准备 movf bits,w andlw 04h movwf inter movf PORTA,w andlw 0Xfb iorwf inter,w ;输出第7位 movwf PORTA bsf PORTA,1 ;发出一脉冲信号 rlf bits,1 decfsz count goto loop bsf PORTA,0 ;送锁存信号
rrf bits1,1 movf bits1,w movwf bits decfsz count1 goto loop1 goto main end