完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我有一个配置25MHz时钟有或没有5倍PLL有困难。我已经创建了一个最小的项目,只有一个“紧”的环,它只振荡一个已知引脚上的输出,我在我的示波器上读取一个35913kHz到355.19kHz的频率。我可以看到一个健康的25MHz正弦波上的OSC1/OSC2引脚考虑。OSCCon=0x0AsTunt= 0x40i有一个旧的MPLAB 8.92项目,是为一个类似的18F97 J60板编写。对于一个类似的回路,它会在振荡引脚上返回一个健康的1.73MHz频率。我很难理解我做错了什么。MPLAB-X V3.55,XC8 V1.40,MCC V3.23.2
以上来自于百度翻译 以下为原文 Hello. I am having trouble configuring a 25MHz clock with or without 5x PLL. I have created a minimal project with a 'tight' while loop that only oscillates the output on a known pin I am reading a frequency on that pin of 359.13kHz to 359.19kHz on my oscilloscope. I can see a healthy 25MHz sine wave on the OSC1 / OSC2 pins though. // Configuration bits: selected in the GUI // CONFIG1L #pragma config WDT = OFF // Watchdog Timer Enable bit->WDT disabled (control is placed on SWDTEN bit) #pragma config STVR = OFF // Stack Overflow/Underflow Reset Enable bit->Reset on stack overflow/underflow disabled #pragma config XINST = OFF // Extended Instruction Set Enable bit->Instruction set extension and Indexed Addressing mode disabled (Legacy mode) #pragma config DEBUG = OFF // Background Debugger Enable bit->Background debugger disabled; RB6 and RB7 configured as general purpose I/O pins // CONFIG1H #pragma config CP0 = OFF // Code Protection bit->Program memory is not code-protected // CONFIG2L #pragma config FOSC = HSPLL // Oscillator Selection bits->HS oscillator, PLL enabled and under software control #pragma config FOSC2 = ON // Default/Reset System Clock Select bit->Clock selected by FOSC1:FOSC0 as system clock is enabled when OSCCON<1:0> = 00 #pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable->Fail-Safe Clock Monitor disabled #pragma config IESO = OFF // Two-Speed Start-up (Internal/External Oscillator Switchover) Control bit->Two-Speed Start-up disabled // CONFIG2H #pragma config WDTPS = 32768 // Watchdog Timer Postscaler Select bits->1:32768 // CONFIG3L #pragma config EASHFT = ON // External Address Bus Shift Enable bit->Address shifting enabled; address on external bus is offset to start at 000000h #pragma config MODE = MM // External Memory Bus->Microcontroller mode, external bus disabled #pragma config BW = 16 // Data Bus Width Select bit->16-Bit Data Width mode #pragma config WAIT = OFF // External Bus Wait Enable bit->Wait states for operations on external memory bus disabled // CONFIG3H #pragma config CCP2MX = ON // ECCP2 MUX bit->ECCP2/P2A is multiplexed with RC1 #pragma config ECCPMX = ON // ECCP MUX bit->ECCP1 outputs (P1B/P1C) are multiplexed with RE6 and RE5; ECCP3 outputs (P3B/P3C) are multiplexed with RE4 and RE3 #pragma config ETHLED = ON // Ethernet LED Enable bit->RA0/RA1 are multiplexed with LEDA/LEDB when Ethernet module is enabled and function as I/O when Ethernet is disabled #include "mcc.h" OSCCON = 0x0A OSCTUNE = 0x40 TRISEbits.RE1 = 0; while (1) { // Add your application code LATEbits.LATE1 = ~LATEbits.LATE1; } I have an old MPLAB 8.92 project that was written for a similar 18F97J60 board. For a similar loop this returns a healthy 1.73MHz frequency on the oscillated pin. I struggle to understand what I am doing wrong? MPLAB-X v3.55, XC8 V1.40, MCC V3.26.2 |
|
相关推荐
9个回答
|
|
如果更改了编译器,也不能保证相同的C代码将执行相同的时间(即汇编指令)。
以上来自于百度翻译 以下为原文 If you changed compiler too, there's no guarantee that the same C code will take the same amount of time (i.e. assembler instructions) to execute. |
|
|
|
我不使用相同的代码,它是一个用MPLAB-X和XC8创建的新的最小项目。我的最终目标是使用TCP/IP Lite创建一个新项目。(如果它使用有线以太网的18F97 J60工作)。
以上来自于百度翻译 以下为原文 I am not using the same code. It is a new minimal project created with MPLAB-X and XC8. My ultimate goal is to create a new project using TCP/IP Lite. (If it works with the 18F97J60 using cabled Ethernet.) |
|
|
|
嗨,PIC18F97 J60有一个内部PLL(X5),以及一个预定标器和一个后定标器,需要根据您的需要来设置正确的系统频率(请看第3.6节)。
以上来自于百度翻译 以下为原文 Hi, The PIC18F97J60 has an internal PLL (x5) as well as a pre-scaler and a post-scaler which need to be setup according to your need to get the correct system frequency (look at section 3.6). Regards |
|
|
|
谢谢。正如你可以看到的例子代码,HS(外部25MHz晶体)已被选中,连同PLL在软件控制。我仍然遗漏什么?
以上来自于百度翻译 以下为原文 Thank you. As you can see by the example code, the HS (External 25MHz crystal) has been selected, together with PLL under software control. Am I still missing something? |
|
|
|
嗨,正如ChanZig提到的,你的程序的频率取决于编译器优化……你需要使用一个定时器来闪烁你的LED在一个已知的频率。此外,你必须比较OSCCon和OSCOTE的设置从你的原始程序和新程序,以确保它们匹配…R。埃加德
以上来自于百度翻译 以下为原文 Hi, As Mentioned by CinziaG the frequency of your program depends striclty upon the compiler optimization... You need to use a timer to blink your LED at a known frequency. Also, you must compare the setup of OSCCON and OSCTUNE from your original program and the new program to make sure they match... Regards |
|
|
|
谢谢你的回应。我认为这是一个误解。我用一个紧密的环把一个销作为一个“蘸棍”摆动到FoSC的结果中。因此,我张贴的代码应该配置的设备使用外部25 MHz晶体振荡器与5X锁相环。我不使用PrimaCe或后标,所以根据表3-2在18F97 J60数据表中,这将导致时钟频率为25MHz或FoCC/4的6250000。即使允许编译器优化和循环控制代码的开销,我也希望看到PIN的振荡。2兆赫的区域。肯定不是只有360kHz。我错了吗?如果是这样,那么那些FoCC/4 MHz去哪里了?所以问题是:我用MCC配置了一个25MHz的振荡器,导致了上面的代码。显然,我的测量结果表明,我没有25兆赫。那么,我可能做了什么错事呢?谢谢您。
以上来自于百度翻译 以下为原文 Thanks for the response. I think there is a misconception. I am using a tight loop to oscillate a pin as a "dip-stick" into the Fosc result. So the code I posted should be configuring the device to use the external 25 MHz crystal oscillator with 5x PLL. I am not using Prescale or Postscale so according to Table 3-2 in the 18F97J60 datasheet this should result in a Clock Frequency of 25MHz or Fosc/4 of 6,250,000. Even allowing for poor compiler optimisation and the overheads of the loop control code I would expect to see an oscillation of the pin in the region of 2 MHz. Definately NOT a mere 360kHz. Am I wrong? If so then where did all those Fosc/4 MHz go? So the question is this: I used MCC to configure a 25MHz oscillator which resulted in the above code. Clearly my measured results show that I don't have 25 Mhz. So what might I have done wrong? Thank you. |
|
|
|
你应该检查(或发布)反汇编代码(生成的汇编代码)——检查“执行多长时间”,因此实际时钟。360kHz的唯一方法将意味着每一关都要使用1.5 USEC循环,这意味着1500/160(纳秒每指令25/4兆赫)=10条指令。完全允许,IMO,对于上述代码,特别是如果未优化。
以上来自于百度翻译 以下为原文 You should check (or post) the disassembly code (generated assembler code) - the only way to check "how long it takes" to execute and hence the actual Clock. 360KHz would mean that every pass takes 1.5uSec circa, which would mean 1500/160 (nanoseconds per instruction @25/4 MHz) = 10 instructions. Perfectly allowable, IMO, for the above code, especially if unoptimized. |
|
|
|
谢谢,这很有帮助。所以我并不是说我产生了不正确的代码,而是我的期望对于那些没有被优化的代码来说太高了。我想这就结束了这件事。再次感谢。
以上来自于百度翻译 以下为原文 Thank you. That is very helpful. So I it's not that I have generated incorrect code, but rather that my expectations are too high for the code that has not been optimised. I think that closes the matter. Thanks again. |
|
|
|
好啊!欢迎回到原来的问题,你想理解“为什么有一个与旧的情况和当前的区别”。当涉及到速度检查时,除了使用RISC上面所建议的定时器之外,我猜想你可以实现一个紧密的汇编循环,例如:BTG迟,2;GOTO循环;}应该正好3个周期并使用它作为参考。(不确定编译器中嵌入C源的汇编代码的确切语法,所以可能需要更改)
以上来自于百度翻译 以下为原文 Ok! you're welcome Back yo your original question, you wanted to understand "why there was a difference from old situation and current one". When it comes to speed checking, apart from using a timer as suggested above by Risc, I guess that you could implement a tight Assembler loop, such as: __asm { loop: BTG LATE,2; goto loop;} which should take exactly 3 cycles and use it as a reference. (am not sure about exact syntax for assembler code embedded into C sources on your compiler, so you may need to change that) |
|
|
|
只有小组成员才能发言,加入小组>>
5202 浏览 9 评论
2016 浏览 8 评论
1942 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3188 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2243 浏览 5 评论
753浏览 1评论
640浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
545浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
652浏览 0评论
552浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-4 10:38 , Processed in 1.402952 second(s), Total 62, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号