Re: 請教關於dsPIC33FJ16GS502的PWM輸出
|
||||
---|---|---|---|---|
版主
|
是設定 dsPIC33F 的震盪工作頻率 Fosc ; 詳細的說明要參考底下有關 OSC 詳細的使用說明:
http://ww1.microchip.com/downloads/en/DeviceDoc/70307B.pdf 章節裡的 42.7 PHASE-LOCKED LOOP (PLL) 有震盪器頻率示意圖及其計算公式,你沒有這一頻率的設定當然程式不會動。 基本上你一定要遵照附件的頻率要求,並按照此公式 Fosc= Fin*M/(N1*N2), 才能正確的算出你所要的 Fosc,Fosc 必須<=80MHz. Attach file: (0.00 KB)
發表於: 2009/5/14 12:05
|
|||
|
請教關於dsPIC33FJ16GS502的PWM輸出
|
||||
---|---|---|---|---|
初級會員
|
請問很多範例程式中都有以下的程式碼
/* Configure Oscillator to operate the device at 40Mhz Fosc= Fin*M/(N1*N2), Fcy=Fosc/2 Fosc= 7.37*(43)/(2*2)=80Mhz for Fosc, Fcy = 40Mhz */ /* Configure PLL prescaler, PLL postscaler, PLL divisor */ PLLFBD=41; /* M = PLLFBD + 2 */ CLKDIVbits.PLLPOST=0; /* N1 = 2 */ CLKDIVbits.PLLPRE=0; /* N2 = 2 */ __builtin_write_OSCCONH(0x01); /* New Oscillator FRC w/ PLL */ __builtin_write_OSCCONL(0x01); /* Enable Switch */ while(OSCCONbits.COSC != 0b001); /* Wait for new Oscillator to become FRC w/ PLL */ while(OSCCONbits.LOCK != 1); /* Wait for Pll to Lock */ /* Now setup the ADC and PWM clock for 120MHz ((FRC * 16) / APSTSCLR ) = (7.37 * 16) / 1 = ~ 120MHz*/ ACLKCONbits.FRCSEL = 1; /* FRC provides input for Auxiliary PLL (x16) */ ACLKCONbits.SELACLK = 1; /* Auxiliary Oscillator provides clock source for PWM & ADC */ ACLKCONbits.APSTSCLR = 7; /* Divide Auxiliary clock by 1 */ ACLKCONbits.ENAPLL = 1; /* Enable Auxiliary PLL */ while(ACLKCONbits.APLLCK != 1); /* Wait for Auxiliary PLL to Lock */ 請問設定這些的用意如何? 因為之前自己寫的程式沒加上這些就無法執行
發表於: 2009/5/14 11:11
|
|||
|