• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






有關計時...
#1
中級會員
中級會員


查看用戶資訊
大家好 有關之前按鍵與震盪器的問題已順利解決 謝謝大家的協助 目前遇到的困難是 當我想以按下按鍵的次數來累加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
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... ]

教育訓練中心

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