movwf DDATA call Write7219 call Delay1ms movlw 0x06 movwf DCOMMAND movlw 0x05 movwf DDATA call Write7219 ;bit5 is 5 call Delay1ms ;Begin Display movlw 0x0c movwf DCOMMAND movlw 0x01 movwf DDATA call Write7219 ;write in 0c01H, exit shut down state. call Delay1s ;wait for 3 seconds. ;call Delay1s ;call Delay1s ;movlw 0x0c ;movwf DCOMMAND ;movlw 0x00 ;movwf DDATA ;call Write7219 ;write in 0c00H, shut down MAX7219. call Delay1s return AddressTable ;list of display data addwf PCL retlw 0x0 ;NO-OP retlw 0x1 ;DIG 0 retlw 0x2 ;DIG 1 retlw 0x3 ;DIG 2 retlw 0x4 ;DIG 3 retlw 0x5 ;DIG 4 retlw 0x6 ;DIG 5 retlw 0x7 ;DIG 6 retlw 0x8 ;DIG 7 retlw 0x9 ;DECODE MODE retlw 0xa ;INTENSITY retlw 0xb ;SCAN LIMIT retlw 0xC ;SHUIDOWN Write7219 ;this function use address 0x0c,0x0d,0x0e,0x0f. ;address 0x0c is data send to MAX7219 ;address 0x0d is display command ;address 0x0e is display data ;address 0x0f is cont used ;write address 0x0c to MAX7219 each time bcf 0x06,2 ;set LOAD is low and MAX7219 begin to recive data movlw 0x08 movwf 0x0f movf DCOMMAND,w ;send display address to MAX7219 movwf 0x0c call SendData movlw 0x08 movwf 0x0f movf DDATA,w ;send display data to MAX7219 movwf 0x0c call SendData ;set a puls from LOAD to MAX7219 bcf 0x06,2 ;LOAD = 0 bsf 0x06,2 ;LOAD = 1 nop ;wait 3 comand times. nop nop bcf 0x06,2 ;LOAD = 0 nop return SendData ;this function is used to send data in address 0x0c to MAX7219 from the high est place. bcf 0x06,3 ;CLOCK = 0 bcf 0x06,1 ;DATA = 0 btfsc 0x0c,7 ;if bit7 of 0x0c is 0 then skip next command. bsf 0x06,1 ;DATA = 1 nop nop nop ;wait 3 command times. nop nop bsf 0x06,3 ;CLOCK = 1 nop nop nop ;delay 5 comand times and clean the Watchdog. clrwdt nop nop nop nop nop bcf 0x06,3 ;CLOCK = 0 rlf 0x0c,1 ;0x0c move left a bit. decfsz 0x0f,1 ;0x0f = 0x0f - 1, if x00f = 0 then return to Write7219. goto SendData return Delay1ms movlw 0x28 ;0x25 = 40D = 28H movwf 0x0c delay1ms_loop1 movlw 0x05 movwf 0x0f delay1ms_loop2 ;40 * 25 = 1000 us = 1ms clrwdt ;clean watchdog decfsz 0x0f,1 goto delay1ms_loop2 decfsz 0x0c,1 goto delay1ms_loop1 return Delay1s movlw 0xce ;every time use 4.85ms, 1000/4.85=206.1D=CEH movwf 0x1a delay1s_loop1 movlw 0x05 movwf 0x1b delay1s_loop2 ;4.85 ms * 206 = 1 s clrwdt call Delay1ms decfsz 0x1b,1 goto delay1s_loop2 decfsz 0x1a,1 goto delay1s_loop1 return end 摘自ec66.com
|