• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   1 Anonymous Users






請問儲存控制時間
#1
中級會員
中級會員


查看用戶資訊
大家好
請問一下 如果要以按鈕的次數來儲存所需要的時間 要如何撰寫 例如每按一次按鈕增加十秒鐘 然後在輸出來控制LED
謝謝

我的程式如下
list p=16F873a
#include <p16f873a.inc> ; Include file locate at defult directory
;#define RA4 PORTA,4

VAL_500uS equ .250 ; 0.5ms delay value
VAL_1s equ .200 ; 10mS delay value
count_1m equ 0x22
count_5s equ 0x23
count_1s equ 0x24
count_us equ 0x25
Reg_time equ 0x26

;********************************************


;*********************************************
org 0x00
nop
initial:


banksel ADCON1 movlw b'11000110'
movwf ADCON1

banksel CMCON movlw b'00000111'
movwf CMCON
movlw b'00110000'
movwf TRISA

banksel TRISB ;定義TRISB設定PORTB為輸出模式
clrf TRISB

banksel PORTB
clrf PORTB



;***********************************************
Main
;***********************************************
start:
clrf Reg_time
movlw b'11111111' ;LED初始狀態
movwf PORTB
movlw .10
movwf Reg_time


;--------------------------------------------------------

key_time:
btfsc PORTA,4
goto add_time
btfsc PORTA,5
goto enter_mode
goto key_time

add_time:
movlw .10
addwf Reg_time,1
;goto key_enter
goto key_time

key_enter:
btfsc PORTA,5
goto key_time
;goto key_enter
goto enter_mode


enter_mode:
call delay_1s
movlw b'00000000'
movwf PORTB

decfsz Reg_time
goto enter_mode
goto clear_mode
clear_mode:
movlw b'11111111'
movwf PORTB
goto start

;-----------------------延遲1s-------------------------------------------
delay_1s:
movlw VAL_1s
movwf count_1s
loop_1s call delay_0.5ms
decfsz count_1s,F
goto loop_1s
return
;-----------------------延遲0.5ms----------------------------------------
delay_0.5ms:
movlw VAL_500uS
movwf count_us
dec_loop nop
nop`
nop
nop
nop
decfsz count_us,F
goto dec_loop
return
;---------------------------------------------------------------------------

end

發表於: 2005/12/21 20:04
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------