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


Browsing this Thread:   1 Anonymous Users




« 1 2 (3) 4 5 »


Re: Regarding to Timer0
#22
資深會員
資深會員


查看用戶資訊
呵呵~對呀,還每4小時宰鴨一次.

哈,小弟已經結緍了呀...早上8點到晚上8點差不多10個鐘頭呀,但當然不是都盯著程式看,也要找找資料和同事討論工作分配...
嗯,用64US是少了一點,其實用128US會比較會適合.

timer程式的原則是程式碼愈短愈好,因為
timer的時間(128us)=timer裡的程式+timer外的程式
也就是說128us以內一定要呼叫一次timer不然時間會不準,所以timer的程式寫的愈短,timer外的程式才能寫的愈長.
也就是說大部分的程式碼都會用到的才加入timer.

至於要怎麼應用就要看你的功能而定,這只是timer程式的基本型配合(只有最基本的時間延遲)應用則有很多的變型,但是大同小異,大原則不變,愈短愈好.
timer能做的事很多,包括接收RF信號,同時還能發射RF信號,但收發的腳位要用2支腳,也就是說能做到信號雙向收發的功能(2WAY),總之視所需要的功能來修改,再慢慢討論吧.

發表於: 2007/9/1 1:25
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Regarding to Timer0
#21
資深會員
資深會員


查看用戶資訊
哇... 程式有病毒呦.... 笨鴨被宰啦 !!! 哈... 哈 ....

其實笨鴨臉皮之厚, 已經是百毒不侵啦 !!!!
臉皮不夠厚, 如何追咩咩呀 ?? hahaha.
還好老婆不會到這個網站來, 呵..呵... 安啦 !!

3Q yiming ! 正好是 Long weekend , 可以研究一下此程式囉!

Tmr0 大致是了解, 現在是研究如何融合在主程式中,而不影響到主程式;
大鍋以前是提到分割成100us 跑主程式;
那偶的主程式不知道應該如何分割了;
嗯... 讓偶 好好 想一想囉 !!! 謝謝啦 !!!

By the way , 問個私人問題 不知 yiming 大鍋 結婚分沒?
偶想... 應該還沒有, Am I right ?
不然如何每日花10小時來看程式呀? 對不? 哈... 哈 ....

休息一下囉 ! 聽說台灣適婚女性 ( 25-35歲) 是多於男性呦 ?? 呵..呵

Have a nice weekend and take care lor !


發表於: 2007/8/31 23:56
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Regarding to Timer0
#20
資深會員
資深會員


查看用戶資訊
PIC12F508                     FOR    TIMER0                                     08-27-2007
        
#include                <p12F508.inc>                   ; processor specific variables
ConfigureControls the reset pincode protectoscillator selectionWDT.
        
__CONFIG _MCLRE_OFF _CP_OFF _WDT_OFF &_IntRC_OSC
;function addtion
;20070831 mp752 CS:
;
add T5ms,T250ms,T1min,T1hours

;*****************************[Defines Variable Assignments]**************** 
  
cblock 0x08
;        T64us                   ; For timer  register.
        
T5ms                    ; For timer  register.
        
T250ms                  ; For timer  register.
        
T1mins                  ; For timer  register.
        
T1hours                 ; For timer  register.
        
endc
;****************************[Reset Vector]*********************************
        
ORG     0x000           PIC goes here (Origin of codeafter reset.
        
movwf   OSCCAL          Load the oscillator calibration factor.
        
movlw   b'11000101'     Disable wake on pion change and Enable pull-ups resister,prescaler=1:64.
        OPTION                          
;
        
movlw   b'00111100'     Set GP 2,3,4,5 to an inputGPIO 0,1 to outputs.
        
TRIS    GPIO            GP0LED1,GP1 =LED2.
init:
        
movlw   .78
        movwf   T5ms
        movlw   .50
        movwf   T250ms
        movlw   .60
*4
        movwf   T1mins
        CLRF    T1hours
;-----[Main routine]---------------------------------------------------------
start:
        
call    timer           ;64us timer.
        
btfsc   tmr0,0          ;Check T64us register bit 0.
        bsf     GPIO
,0          ;If bit 0 H then turn LED1 ON.
        
btfss   tmr0,0          ;Check T64us register bit 0.
        bcf     GPIO
,0          ;If bit 0 =0 then turn off LED1
        
        
btfsc   tmr0,1          ;Check T64us register bit 1.
        bsf     GPIO
,1          ;If bit 1 H then turn LED2 ON.
        
btfss   tmr0,1          ;Check T64us register bit 1.
        bcf     GPIO
,1          ;If bit 1 0 then turn LED2 OFF.
                
        
movlw   .4
        xorwf   T1hours
,w
        btfss   STATUS
,Z
        
goto    start          
kill_duck
:
        ;
duck is died
        
goto    init

;******************************** Timer Routine ********************************
timer:   
        
btfsc   TMR0,0          ;
        goto    
_T64us_1        ;
_T64us_0
        btfss   TMR0
,0          ;
        goto    
_T64us_0        ;
        goto    
_T64us          ;
_T64us_1
        btfsc   TMR0
,0          ;
        goto    
_T64us_1        ;
_T64us
        
;in this section even 64us do 1 times
        
;you can do some in here
        
;
        
decfsz  T5ms,f  
        
goto    _mq1
        movlw   .78
        movwf   T64us
_T5ms
        
;in this section even 5ms do 1 times
        
;you can do some in here
        
;
        
decfsz  T5ms,f
        
goto    mq1
        movlw   .50
        movwf   T250ms
_T250ms
        
;in this section even 250ms do 1 times
        
;you can do some in here
        
;
        
decfsz  T1mins,f
        
goto    mq1
        movlw   .60
*4
        movwf   T1mins
_T1houts
        incf    T1hours
,f
        
;in this section even 1 hours do 1 times
        
;you can do some in here
        
;
_mq1:
        
retlw   .0    
        end


發表於: 2007/8/31 16:01
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Regarding to Timer0
#19
資深會員
資深會員


查看用戶資訊
這個程式呀? 沒幹啥事, 只是測試一下而已...

我是想如何改為先前提到的 4小時 Timer,
因為先前對TMR0這麼個東東不了解,
經過各位大鍋的詳細解釋 已經大致了了,
現在可以回頭再去看看大鍋的程式囉!

發表於: 2007/8/29 23:36
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Regarding to Timer0
#18
資深會員
資深會員


查看用戶資訊
嗯,不錯哦~
呀,這個程式要拿來做什麼??


發表於: 2007/8/29 20:32
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Regarding to Timer0
#17
資深會員
資深會員


查看用戶資訊
Ha ha ... 改好了(笨鴨 自己看的懂 的方法 ) Run起來 也很正常
程式如下 3Q lar ...
PIC12F508                             FOR    TIMER0                                      08-27-2007
    
#include        <p12F508.inc>            ; processor specific variables
ConfigureControls the reset pincode protectoscillator selectionWDT.
    
__CONFIG _MCLRE_OFF _CP_OFF _WDT_OFF &_IntRC_OSC
;*****************************[Defines Variable Assignments]**************** 
  
cblock 0x08
    T64us            
; For timer  register.

    
endc
;****************************[Reset Vector]*********************************
    
ORG        0x000            PIC goes here (Origin of codeafter reset.
    
movwf        OSCCAL            Load the oscillator calibration factor.
    
movlw        b'11000101'        Disable wake on pion change and Enable pull-ups resister,prescaler=1:64.
    OPTION                        
;
    
movlw        b'00111100'        Set GP 2,3,4,5 to an inputGPIO 0,1 to outputs.
    
TRIS        GPIO            GP0LED1,GP1 =LED2.
;-----[
Main routine]---------------------------------------------------------
start
    call            timer        
;64us timer.
    
btfsc        T64us,0        ;Check T64us register bit 0.
    bsf            GPIO
,0        ; If bit 0 H then turn LED1 ON.
    
btfss        T64us,0        ;Check T64us register bit 0.
    bcf            GPIO
,0        ;If bit 0 =0 then turn off LED1
    
btfsc        T64us,1        ;Check T64us register bit 1.
    bsf            GPIO
,1        ;If bit 1 H then turn LED2 ON.
    
btfss        T64us,1        ;Check T64us register bit 1.
    bcf            GPIO
,1        ;If bit 1 0 then turn LED2 OFF.
    goto        
start        ;
;******************************** 
Timer Routine ********************************
timer    
    btfsc        TMR0
,0        ;
    goto        
_T64us_1    ;
_T64us_0
    btfss        TMR0
,0        ;
    goto        
_T64us_0    ;
    goto        
_T64us        ;
_T64us_1
    btfsc        TMR0
,0        ;
    goto        
_T64us_1    ;
_T64us
    incf            T64us
,f        ;
    
retlw        0            ;
    
end



發表於: 2007/8/29 1:03
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PSIR
#16
資深會員
資深會員


查看用戶資訊
笨鴨也是三年前, 看到林茂榮, 登錄在電子情報 用PIC做PIC 的文章,引起興趣的;
那時簡直是笨蛋一個, 只會一些邏輯IC來製造;
真是又笨又一大堆, 往往設計錯誤,一改就是一大堆..
後來發現PIC如此簡潔, 所以來此求教...

記得還是版主Ryang, 寫一個簡單PIC10F200 LED程式, 就醬子玩起來...
承蒙abewu大鍋的教導及 後續各位大鍋的細心, 耐心指導;
笨鴨穫益多多, 在此一鞠躬 ,說聲, 謝謝 ,,阿里阿多 ,,3Q 啦!!!
有機會回台 得擺一桌謝謝各位大鍋囉 !

家裡都是自動化控制?? 是有這個打算耶 !
已經完成一部份 X'mas LED 跑燈, 還有停電自動照明..
再來就是.. 太陽能自動充電系統, 還有空調系統 ....
有的玩啦!! 哈.. 哈..哈...


發表於: 2007/8/28 23:44
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PSIR
#15
資深會員
資深會員


查看用戶資訊
呵呵~7年前學單晶片,那可真的粉辛苦了,資料少的可憐可利用的資源也不多能問的人更少只有自己做白老鼠了,現在輕鬆多了可選用的MCU粉多又便宜還可以要樣品,電路程式都有現成的,多幸福快樂呀,相對的寫程式的人身份地位就大不如前了.

何況鴨子也不是靠這個混飯吃,只是看家裡的台燈不順眼加個PIC改造一下,閒著無聊搞東搞西的,等鴨子功力夠強,應該整個家裡都是是自動化控制了吧....^^~

發表於: 2007/8/28 10:12
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Regarding to Timer0
#14
資深會員
資深會員


查看用戶資訊
其實計時的程式就是每隔多久固定的時間就去做某件事情而已,

例如每1ms就進Timer0中斷程式將某個暫存器加1,加滿10次就歸零並做某一個動作,

或是令某個I/O反相一次,這樣就可以得到一個1ms High, 1ms Low的方波,這就是time base(時基)。

有了固定的time base,就可以做更長時間的計時了。

看到鴨先生的心情就想起七年前的我也是這樣辛苦的在學單晶片,

鴨先生只是尚未突破那個思考的盲點而已,只要勤練習總有一天一定會開竅的,加油。



發表於: 2007/8/28 9:52
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Regarding to Timer0
#13
資深會員
資深會員


查看用戶資訊
那這種timer的使用方式你就懂了,接下來再增加一些應用就差不多了...

嗯,主程式最多不可以超過64行,超過就要再呼叫一次timer..
可以調整timer0 prescaler rate 1:128,主程式就可以128行了,至於prescaler rate要設多少就視你的應用了.

movlw .10*4
subwf T250ms,w
btfsc status,c
goto ....
應該之前的程式加了一些應用,時間單位是250mS,.10*4一看就知道是10秒的時間,如果換成movlw .40可讀性差一點.
這種寫法對以後修改程式也有幫助,movlw .52*4就是52秒,movlw .208你知道是多少秒??

發表於: 2007/8/28 8:25
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... ]

教育訓練中心

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