[英]why this code in asm (MPLAB x) doesn't work (on/off led)
#include p16f88.inc
;----------memory data--------
program org 0x00
goto preparation
Preparation
bsf status,RP0
bsf trisb,trisb0 ; load port rb0 as input
bcf trisb,TRISB4 ; load port rb4 as output
bcf status,RP0
goto begin
;---------------begin---------------
begin
btfss portb,rb0
goto begin
goto on
on
bsf portb,rb4
goto begin
end
我的意思是我可以領導,但我不能做到。 當我離開按下按鈕時,我必須做些什么?
最好的祝福。
編輯:現在,我將其添加到代碼中,但是當我按下開關3或4次時,指示燈熄滅了?
program org 0x00
goto preparation
Preparation
bsf status,RP0
bsf trisb,trisb0 ; load port rb0 as input
bcf trisb,TRISB4 ; load port rb4 as output
bcf status,RP0
goto begin
;---------------begin---------------
begin
btfss portb,rb0
goto begin
goto on
on
bsf portb,rb4
btfsc portb,rb0 /* <---------- I add this part*/
goto begin /* <---------- for off the led*/
bcf portb, rb4 /* <---------- again*/
goto begin
end
proteus是否正常?或者我的代碼還可以嗎?
在開關輸入端添加一個下拉電阻,然后嘗試以下操作:
program org 0x00
goto preparation
Preparation
bsf status,RP0
bsf trisb,trisb0 ; load port rb0 as input
bcf trisb,TRISB4 ; load port rb4 as output
bcf status,RP0
goto begin
;---------------begin---------------
begin
btfss portb,rb0
goto begin
goto on
on
bsf portb,rb4
btfsc portb,rb0
goto on ;don't go to begin but keep testing for the switch to be released
bcf portb, rb4
goto begin
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.