• slider image 442
  • slider image 492
  • slider image 493
  • slider image 494
  • slider image 495
  • slider image 496
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: Delay time
#3
新會員
新會員


查看用戶資訊
可以用Timer2的計時中斷,因Timer2有自動回歸,所以很方便
用Timer2做1mS中斷,再來做Delay就非常準喔!
宣告 intTimer 為公用變數

int intTimer = 0;

void Delay(int intDelay)
{
intTimer = intDelay; // intDelay 單位為 1mS
while(intTimer != 0);
}

中斷程式
void Timer2(void)
{
if(intTimer>0)
intTimer--;

.............
.........
}

那你要做多久的Delay都沒問題,而且超神準的.....

發表於: 2007/5/4 15:47
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: Delay time
#2
版主
版主


查看用戶資訊
用 C 算 deley 很難拿捏的準,但不管怎樣 C 的 DELAY 函數的執行時間基本上是固定的。要知道詳細的 DELAY 時間可以用 MPALB SIM 配合 Stepwatch (須先設定模擬頻率) 來測量 Delay 的時間。

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


Delay time
#1
高級會員
高級會員


查看用戶資訊
Dear all,

我想寫一段精準的delay time (ex.10 micro sec),讓程式中有需要dealy的地方就呼叫此delay function。(不想使用到計時器)
因為我是用C開發MCU,所以我採用in-line的方式去實現delay:
void dealy(int time)
{
int i;
for(i=0;i<time;i++)
asm("nop");
}
我目前是利用這函數去delay,但不太準,請問還有更好的方法能精準產生micro sec delay嗎?

謝謝

發表於: 2007/4/27 19:03
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... ]

教育訓練中心

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