|
楼主 |
发表于 2008-5-10 07:00:30
|
显示全部楼层
程序(试验1)
;-------------------------------------
; File: JLED100.asm
; For Julie Rotational LED Clock
; H/W: PIC16F84, 4MHz Crystal
; Ver: 0.00
; Date: 08/05/2008 By: Julie Jean
;-------------------------------------
list p=16f84
include "p16f84.inc"
;------------- Variable ------------
cblock 0Ch
temp ; b0=sync
i ; for delay
coln ; display column
digit ; display digit
tot ; total offset
endc
;-------- Start ---------
org 0h
goto Main
org 4h
retfie
;-------- Table ----------
Table addwf PCL,1
dt 0C1h,0BEh,0BEh,0BEh,0C1h ; "O"
dt 0FFh,0FEh, 80h,0DEh,0FFh ; "1"
dt 0CEh,0B6h,0BAh,0BCh,0DEh ; "2"
dt 0B9h, 96h,0AEh,0BDh,0BEh ; "3"
dt 0FBh, 80h,0DBh,0EBh,0F3h ; "4"
dt 0B1h,0AEh,0AEh,0AEh, 8Dh ; "5"
dt 0F9h,0B6h,0B6h,0D6h,0E1h ; "6"
dt 9Fh,0AFh,0B7h,0B8h,0BFh ; "7"
dt 0C9h,0B6h,0B6h,0B6h,0C9h ; "8"
dt 0C3h,0B5h,0B6h,0B6h,0CFh ; "9"
dt 0FFh,0FFh,0C9h,0C9h,0FFh ; ":"
;-------- Init -------
Init movlw 03h
tris PORTA ; RA0=sync(input), RA1=remote(input), RA2=motor(output)
clrw
tris PORTB ; RB0-RB7=LEDs(all output)
Var_ini clrf coln
clrf digit
movlw 0FFh
movwf PORTB
bsf temp,0
return
;-------- Processing -------
Proc btfss PORTA,0 ; sync
bcf temp,0
return
;-------- Display -------
Disp btfsc temp,0
return
La movf coln,0
addwf digit,0
movwf tot
xorlw 36h
btfsc STATUS,Z
goto Var_ini
movf tot,0
call Table
movwf PORTB
call Di ; short delay
incf coln,1
movf coln,0
xorlw 5h
btfss STATUS,Z
goto La
movlw 5h
addwf digit,1
clrf coln
call Sp
goto La
Sp movlw 0FFh ; spacing
movwf PORTB
call Daa ; long delay
return
;-------- Delay ------------
Daa movlw 0AFh ; long delay daa
goto Delay
Di movlw 01Fh ; short delay di
Delay movwf i
Loop decfsz i,1
goto Loop
return
;-------- Update -------
Update nop
return
; -------- Main -----------
Main call Init ; init
Run call Proc ; processing
call Disp ; display
call Update ; Update
goto Run
end |
|