编辑:PIC 16F684
好的,我有一个简单的 3 LED 二进制时钟,从 0 到 7 计数,并且想在每次打开灯之间添加大约 1 秒的延迟。
我已经确定每个灯都需要处于某种循环中,并且我必须使用计数来测量刻度和翻转等。
我认为时钟是 4MHz,这是手册的截图:http: //i.imgur.com/tJatQ.png
这是我的代码中的相关摘录:
COUNT1 EQU 20h ; Delay counter #1
COUNT2 EQU 21h ; Delay counter #2
...
LOOP0
MOVLW TRIS_D0_D1 ; Move value defined in Constants to TRISA, to switch on LED 0.
TRIS PORTA ;
CLRF PORTA ; Clear all outputs.
MOVLW D0 ; Set the accumulator to the value of D0.
MOVWF PORTA ; Move the accumulator to PORTA, to switch on LED 0.
; Using COUNTs to add a delay
decfsz COUNT1,1 ; Decrease COUNT1 by 1, and skip the next line if the result is 0.
goto LOOP0 ; If COUNT1 is 0, carry on. If not, go to LOOP0.
decfsz COUNT2,1 ; Decrease COUNT2 by 1, and skip the next line if the result is 0.
goto LOOP0 ; If COUNT1 is 0, carry on. If not, go to LOOP0.
但是,我很确定我搞砸了时间,有人可以帮帮我吗?