• 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 »


Re: 關於使用 internal oscillator
#12
版主
版主


查看用戶資訊
1. 8MHz OSC 指令週期為 0.25uS (4MHz Fosc),與 5uS有40個指令執行時間,但 PIC18F 刻意執行到 40MHz 的速度,這時速度就非常快了。
2. 硬體的 PWM 的使用彈性是很大的,不曉得你是否有了解 PIC 的 PWM Module 動作情形。
參照:
PWM Module 的週期無法拉到我希望的長度

看了以後真的不了解你的需求? Period 要多長?

3. Timer1 & Timer2 的差異看 Data Sheet 裡的方塊圖就知道了。

4. 看 MPLAB IDE 下,Configuretion 的選項就有你目前的設定值。

發表於: 2007/12/18 11:48
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於使用 internal oscillator
#11
初級會員
初級會員


查看用戶資訊
恩,謝謝回答

照理來講,如果用 internal oscillator, 可以調到 8Mhz, 不是就 5uS 並不難做到。還是我觀念錯了?

另外,我有用過 PWM Module, 不過因為我將來要調整他的週期, PWM Module 的週期無法拉到我希望的長度,所以考慮自己寫 PWM。
另外,利用 Timer2 和利用 Timer1 的差別是什麼?
謝謝

最後,那些 Configuration Bits, 我如何知道我的設定已經調整好到我想要的? 意思是說,internal oscillator 該調哪些?

再次謝謝

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


Re: 關於使用 internal oscillator
#10
版主
版主


查看用戶資訊
5uS 用 Timer1 並不適合因為時間很短,可以考慮用 Timer2 的方式,因為 Timer2 有 Auto reload Timer 值的功能。不過還是建議直接使用 PWM Module 最簡單,5uS 一點也不難辦到。
如果在程式力直接設定 Configuration 有問題,考慮一下直接在 MPLAB IDE 的 Configuretion Bits 選項下直接選擇你要的設定項後,燒錄完成再測試一下 Clock 輸出對不對,這樣比較簡單。

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


Re: 關於使用 internal oscillator
#9
初級會員
初級會員


查看用戶資訊
各位
麻煩大家
急需這部分
不知道是不是忘記設定什麼
還是哪裡設定錯了?
再次謝謝

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


Re: 關於使用 internal oscillator
#8
初級會員
初級會員


查看用戶資訊
我不太確定 TIMER1 是怎麼用的
不好意思,不太懂你的意思
如果不是這樣用
那請問,要如何用?

以下是我的程式碼


#include <p18f4480.h> //納入微控制器定義檔
#include <timers.h> //納入計時器函式庫定義檔


#pragma config BOREN=OFF, BORV = 2, PWRT=ON, WDT=OFF, LVP=OFF
#pragma config OSC = IRCIO67




#define TMR1_VAL 65536-1//65536-16384 // Timer1 設定為 500ms 中斷一次

//宣告函式原型
void Init_TMR1(void);
void timer1_isr (void);

//宣告並安排中斷執行程式記憶體位置
#pragma code low_vector=0x18
void low_interrupt (void)
{
_asm GOTO timer1_isr _endasm
}
#pragma code

#pragma interruptlow timer1_isr

int i;

void timer1_isr (void)
{
PIR1bits.TMR1IF = 0; // 清除中斷旗標
WriteTimer1(TMR1_VAL); // 當將計數器觸發次數歸零寫入預設值
PORTD=PORTD^0xff;
PORTC=PORTC^0xff;

}

void main (void) {


PORTD = 0x00; // 將PORTD清除關閉LED
TRISD = 0; // 將TRISD設為0,PORTD設定為輸出
PORTC = 0x00;
TRISC = 0;
i = 0;

Init_TMR1(); // 初始化設定Timer1函式

INTCONbits.PEIE = 1; // 開啟周邊中斷功能
INTCONbits.GIE = 1; // 開啟全域中斷控制

while (1); // 無窮迴圈
}

void Init_TMR1 (void){


T1CON = 0b10000101;
TMR1H=0;
TMR1L=0;
OSCCON =0x7F;
PIE1bits.TMR1IE=1;
WriteTimer1(TMR1_VAL); // 寫入預設值
PIR1bits.TMR1IF = 0; // 清除中斷旗標

}


麻煩幫我看一下
我想要做到的是
就是,每 5microseconds (或比 5 microseconds 還要小的) 時間讓其中一支 output 可以從HIGH變LOW 在變 HIGH 這樣重複,做出一個 PWM 訊號

謝謝各位
我對 PIC 很不熟
請多多指教

p.s. 我把 OSC & OSCCON 改成你說的
結果還是大概 67 microseconds

發表於: 2007/12/17 14:31
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於使用 internal oscillator
#7
資深會員
資深會員


查看用戶資訊
你這樣用 TIMER1 跟本不會是你要的
你確定 TIMER1 是這樣用的?



這兩行,就能確保 使用 內部 8MHZ
#pragma config OSC = IRCIO67
OSCCON =0x7F;

發表於: 2007/12/17 14:15
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於使用 internal oscillator
#6
初級會員
初級會員


查看用戶資訊
#pragma config OSC = HS, BOREN=OFF, BORV = 2, PWRT=ON, WDT=OFF, LVP=OFF

不好意思
上面忘記貼上去

發表於: 2007/12/17 13:59
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於使用 internal oscillator
#5
版主
版主


查看用戶資訊
不清楚你是怎樣設定 Configuration 的,貼上程式設定來看看?

發表於: 2007/12/17 13:50
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於使用 internal oscillator
#4
初級會員
初級會員


查看用戶資訊
謝謝你的回覆
我剛剛試了

其實我已經改過一些設定
可是我跑出來的卻還不是我想要的東西
不知道有沒有什麼其他的我忘記設定
我想要讓她跑 8Mhz
可是我量出來的大概只有 38microseconds
差很多
謝謝各位

發表於: 2007/12/17 11:18
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 關於使用 internal oscillator
#3
版主
版主


查看用戶資訊
Configuration 的設定少了許多選項,看一下 configuratin 的設定資料吧!
C:\mcc18\doc\hlpPIC18ConfigSet.chm 的說明。

--------------------    MPLAB C18   ----------------------------------------

;*******************************************************************************
;*
3.For MPLAB C18 V2.40 or higher, use #pragma config directive                       *
;*for example                            
//******************************************************************************
    #include <p18f452.h>
//*******************************************************************************
//*Configuration settings may be specified with multiple #pragma config directives.          *
//*MPLAB C18 verifies that the configuration settings specified are valid for the processor*
//*for which it is compiling                            
//*The labels following the directive "pragma config" are defined in the P18F452.h file.    *
//*******************************************************************************
    #pragma config    OSC=HS
    #pragma config     PWRT=ON
    #pragma config     BOR=OFF, BORV=42
    #pragma config     WDT=OFF
    #pragma config      CCP2MUX=ON
    #pragma config      STVR=OFF, LVP=OFF, DEBUG=OFF
    #pragma config      CPD=OFF
    
void main(void)
{
//your code
}

發表於: 2007/12/14 18:57
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... ]

教育訓練中心

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