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


Browsing this Thread:   1 Anonymous Users






Re: time delay 程式小問題
#3
新會員
新會員


查看用戶資訊
您好,感謝您的解答,
但是我有點混淆了,
照你的說法,
這個範例程式的FCY應該除以1千而不是1萬囉?
還是說加法會消耗不只一個指令週期?

新手問題很多請多包涵>"<

發表於: 2009/3/10 17:08
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: time delay 程式小問題
#2
新會員
新會員


查看用戶資訊
#define FCY 5000000 // xtal = 5.0Mhz; PLLx4

因為使用5M的震盪晶體,再乘四倍的PLL
PIC本身Pipeline的緣故,還需要除以四
乘四又除四相消,因此單一指令週期時間剛好為5M的倒數

加上延遲副程式要求最小單位是1 ms

單位延遲時間就可以下面式子表示
unit delay time = (1/1000) / (1/5000000)

簡化後,就變成第四行的結果
#define MILLISEC FCY/10000 // 1 mSec delay constant

發表於: 2009/3/10 12:51
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


time delay 程式小問題
#1
新會員
新會員


查看用戶資訊
#define __dsPIC30F2010__
#include <p30F2010.h>

#define FCY 5000000 // xtal = 5.0Mhz; PLLx4
#define MILLISEC FCY/10000 // 1 mSec delay constant

void DelayNmSec(unsigned int N);

// For N = 1 the delay is 1 mS, for N = 65535 the delay is 65,535 mS.
void DelayNmSec(unsigned int N)
{
unsigned int j;
while(N--)
for(j=0;j < MILLISEC;j++);
}

其中的第四行,為什麼"FCY/10000"這樣可以表示成1msec delay?

它有什麼特定規則嗎?

麻煩各位程式高手幫小弟解惑一下,感激不盡!!

發表於: 2009/3/9 11:08
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... ]

教育訓練中心

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