我的代碼如下所示,我試圖使用按鈕來打開和關閉LED。所以按一次就會打開它,它會一直亮着,直到再次按下按鈕。PIC部件 - 檢查按鈕的狀態
但是,在編譯期間出現一個錯誤 - 「地址標籤重複或第二遍不同」 錯誤指向以「check BTFSS」開頭的行的第二次出現。
我在這裏做錯了什麼?
在此先感謝。 :)
;Program name: T code
;CPU Configuration
processor 16F84A
include <p16f84a.inc>
__config _XT_OSC & _WDT_OFF & _PWRTE_ON
;Register Label Equates
PORTA equ 05
PORTB equ 06
Count equ 0C
;Register Bit Label Equates
Input equ 4 ;PUSH BUTTON INPUT RA4
LED1 equ 0 ;LED OUTPUT RB0
;*****Program Start*****
org 0
;Initialize (Default = Input)
movlw B'00000000' ;Define Port B output
tris PORTB ; and set bit direction
goto check
;Main Loop
check BTFSS PORTA,Input ;If button is OFF, goto check, and keep waiting for button HIGH condition.
goto check ;
bsf PORTB,LED1 ;Turn the LED ON
check BTFSS PORTA,Input ;Assuming the LED is currently ON, keep checking for a button press...
goto check
bcf PORTB,LED1 ;Turn the LED OFF
goto check ;repeat always
END
不是PIC程序員,但它看起來像我已經標記了兩行'check',這是混淆了彙編程序。也許你應該給他們貼上'check1'和'check2'。 – 2013-11-01 12:48:05