Browsing this Thread:
1 Anonymous Users
|
有關計時...
|
|
中級會員
Joined
: 2004/10/19 11:53 最後登入時間
: 2006/7/5 15:13
Group:
註冊會員
Level : 5 HP : 0 / 122 MP : 16 / 7014 EXP : 90
|
大家好 有關之前按鍵與震盪器的問題已順利解決 謝謝大家的協助 目前遇到的困難是 當我想以按下按鍵的次數來累加LED發光的秒數 但是結果都只會計數原來暫存器存的10秒 並沒有累加的功能 以下是我的程式 請各位幫我看看 謝謝 list p=16F873a #include <p16f873a.inc> ; Include file locate at defult directory 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:
;bcf STATUS,RP0 ;bcf STATUS,RP1 ;clrf PORTA ;bsf STATUS,RP0 banksel ADCON1 ;定義ADCCON1,將PORTA第四個bit設為數位模式 movlw b'11000110' movwf ADCON1 banksel CMCON ;定義CMCON將比較器功能關閉 movlw b'00000111' movwf CMCON movlw b'00011000' 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 key_enter ;goto key_time goto add_time add_time: addwf Reg_time,1 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/11/28 22:04
|
|
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.