完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,另一个NOOB问题:我似乎不能让PLL工作。我将不再使用数据表示例代码,除非我切换到PrabMA命令。代码:我用的是LED(RA0)和时钟输出引脚来测量。时钟在7.37兆赫。有什么想法吗?
以上来自于百度翻译 以下为原文 Hi, Another noob issue: I can't seem to get the PLL to work. I am going off of the datasheet example code, except I switched to pragma commands. Code: #pragma config GWRP = OFF // General Code Segment Write Protect (User program memory is not write-protected) #pragma config GSS = OFF // General Segment Code Protection (User program memory is not code-protected) // FOSCSEL #pragma config FNOSC = FRC // Oscillator Mode (Internal Fast RC (FRC)) #pragma config IESO = OFF // Internal External Switch Over Mode (Start-up device with FRC, then automatically switch to user-selected oscillator source when ready) // FOSC #pragma config POSCMD = NONE // Primary Oscillator Source (HS Oscillator Mode) #pragma config OSCIOFNC = OFF // OSC2 Pin Function (OSC2 pin has clock out function) #pragma config IOL1WAY = OFF // Peripheral Pin Select Configuration (Allow Multiple Re-configurations) #pragma config FCKSM = CSECMD // Clock Switching and Monitor (Clock switching is enabled, Fail-Safe Clock Monitor is disabled) // FWDT #pragma config WDTPOST = PS32768 // Watchdog Timer Postscaler (1:32,768) #pragma config WDTPRE = PR128 // WDT Prescaler (1:128) #pragma config WINDIS = OFF // Watchdog Timer Window (Watchdog Timer in Non-Window mode) #pragma config FWDTEN = OFF // Watchdog Timer Enable (Watchdog timer enabled/disabled by user software) // FPOR #pragma config FPWRT = PWR128 // POR Timer Value (128ms) #pragma config ALTI2C = OFF // Alternate I2C pins (I2C mapped to SDA1/SCL1 pins) // FICD #pragma config ICS = PGD1 // Comm Channel Select (Communicate on PGC2/EMUC2 and PGD2/EMUD2) #pragma config JTAGEN = OFF // JTAG Port Enable (JTAG is Disabled void init_clk(void) { /* Program PLL for 38MHz from 7.37MHz HS Xtal */ PLLFBD = 38; // PLL FDBK = 41 CLKDIVbits.PLLPOST = 0; // PLL POST = 2 CLKDIVbits.PLLPRE = 0; // PLL PRE = 2 /* Switch clock source to PLL */ //__builtin_write_OSCCONH(3); // NOSC = 3 : HS + PLL //__builtin_write_OSCCONL(1); // OSWEN = 1 : switch clock source __builtin_write_OSCCONH(0x01); __builtin_write_OSCCONL(OSCCON | 0x01); // Wait for Clock switch to occur while (OSCCONbits.COSC != 0b001); // Wait for PLL to lock while(OSCCONbits.LOCK!=1) {}; } I am using the LED (RA0) and also the clock output pin to measure. The clock is at 7.37MHz. Any thoughts? |
|
相关推荐
3个回答
|
|
我有一些EV导数的代码。在这里,这个技巧很简单:应该以类似于F导数的方式工作。
以上来自于百度翻译 以下为原文 I have some code for an EV derivative. There the trick is done quite simple: // Macros for Configuration Fuse Registers _FOSCSEL(FNOSC_PRIPLL); _FOSC(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_XT); // Startup directly into XT + PLL // OSC2 Pin Function: OSC2 is Clock Output // Primary Oscillator Mode: XT Crystal (8 MHz) void oscConfig(void) { // Configure Oscillator to operate the device at 80MHz/40MIPs // Fosc= Fin*M/(N1*N2), Fcy=Fosc/2 // Fosc= 8M*40/(2*2)=80Mhz for 8M input clock // To be safe, always load divisors before feedback !! CLKDIVbits.PLLPOST = 0; // N1=2 CLKDIVbits.PLLPRE = 0; // N2=2 PLLFBD = 38; // M=(40-2), Fcyc = 40MHz for ECAN baud timer // Disable Watch Dog Timer RCONbits.SWDTEN = 0; } Should work in a similar way with the F derivatives. |
|
|
|
事实证明,在代码中包含一个例程是不够的;您实际上还必须调用它;-)它现在工作了。不管怎样,还是谢谢你!
以上来自于百度翻译 以下为原文 It turns out it is not enough to have a routine in your code; you actually have to also call it ;-) Its working now. Thanks anyway! |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5243 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3208 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2258 浏览 5 评论
779浏览 1评论
672浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
598浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
682浏览 0评论
579浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 22:32 , Processed in 1.379863 second(s), Total 103, Slave 87 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号