• slider image 442
  • slider image 497
  • slider image 498
  • slider image 499
  • slider image 500
  • slider image 502
:::


Browsing this Thread:   1 Anonymous Users






Re: 內部震盪
#6
資深會員
資深會員


查看用戶資訊
while(1) 後面沒有把程式片段用 { } 引起來,只有 PORTB=0x00; 會被執行到。

while 與 delay 會花多少 instruction cycle, 建議用 MPLAB SIM 的 stopwatch 功能模擬一下。
還有,stopwatch 會計算週期和時間,先到 debug -> setting 裡設一下 osc freq.,stopwatch 的時間才會準。

(註: PIC 的 1 instruction cycle = 4 clock cycle)


此外,查了一下 datasheet 後,發現另可選擇 INTIO1 模式,令 RA6 送出 Fosc / 4 (此時該腳不能作I/O用)

註: 如果不是要取用這個頻率給其他裝置使用,建議測試完畢後,在正式使用時或量產時改回 INTIO2 模式,以免增加 EMI。


又,C18 有現成的 delay 函數可用:
#include <delays.h>
void Delay1TCY ( void ); // Delay one instruction cycle. (=NOP)
void Delay10TCYx ( unsigned char unit ); // Delay in multiples of 10 instruction cycles.
void Delay100TCYx ( unsigned char unit ); // Delay in multiples of 100 instruction
cycles.
void Delay1KTCYx ( unsigned char unit ); // Delay in multiples of 1,000 instruction
cycles.
void Delay10KTCYx ( unsigned char unit ); // Delay in multiples of 10,000 instruction
cycles.

※ 以上cycle都含 call-return, 但計算程式 cycle 時別漏 while 指令的時間

發表於: 2008/10/7 12:02

Edited by tonys on 2008年10月07日 12:34:52
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 內部震盪
#5
新會員
新會員


查看用戶資訊
我做了一個簡單的內部頻率測試單純讓led亮滅,

但是無法動作,是否沒有頻率??還是設定錯誤呢?

以下是我測試程式~請多指教


#include "p18f1220.h"

#pragma config OSC = INTIO2 //Internal RC, OSC1 as RA7, OSC2 as RA6 RA6 可以量到輸出頻率

void delay1ms(int count)
{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<122;j++);
}

void main(){

TRISB=0x00;
PORTB=0x00;
OSCCON=0x7F;


while(1)
PORTB=0x00;
delay1ms(100);
PORTB=0xFF;
delay1ms(100);



}

發表於: 2008/10/6 16:19
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 內部震盪
#4
版主
版主


查看用戶資訊
設定 Internal 8MHz:

#pragma config OSC = INTIO2 //Internal RC, OSC1 as RA7, OSC2 as RA6 RA6 可以量到輸出頻率

以上之設定須參考 c:\mcc18\doc\hlpPIC18ConfigSet.chm 裡的說明
http://www.microchip.com.tw/modules/w ... /visit.php?cid=12&lid=124

另外選擇內部 8MHz 輸出,用 OSCCON暫存器 :
bit 6-4 IRCF2:IRCF0: Internal Oscillator Frequency Select bits
111 = 8 MHz (8 MHz source drives clock directly)
110 = 4 MHz
101 = 2 MHz
100 = 1 MHz
011 = 500 kHz
010 = 250 kHz
001 = 125 kHz
000 = 31 kHz (INTRC source drives clock directly)

發表於: 2008/10/6 15:22
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 內部震盪
#3
新會員
新會員


查看用戶資訊
請問如何設定內部時鐘頻率8MHZ呢?

另外設定了內部時鐘頻率有何限制呢?

謝謝!


新手請多指教謝謝~

發表於: 2008/10/6 15:16
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 內部震盪
#2
資深會員
資深會員


查看用戶資訊
一般是寫一簡單程式,令 I/O 送出方波,量測其頻率,再由程式送出方波所需的指令週期、時鐘週期的關係,反推確實的時鐘頻率。

內部振盪的出廠誤差範圍,可參見 datasheet

發表於: 2008/10/6 15:10
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


內部震盪
#1
新會員
新會員


查看用戶資訊
我使用pic18f1220,請問如何設定震盪8MHZ,

設定完可以量測到嗎??


新手請多指教謝謝~

發表於: 2008/10/6 14:55
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... ]

教育訓練中心

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