完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,我正在使用一个8MHz的外部振荡器来运行我的设备。到目前为止,我的设备运行。然而,当使用USB通信时,我注意到有一个滞后。我不认为我所有的配置位都是正确设置的。我使用的是PIC24FJ256GB206。我的问题是USB工作,PC找到设备,我的USB测试应用程序可以与设备通信。我有一个简单的ping命令。当我使用内部时钟时,我可以很快地对设备进行快速处理,并且总是能立即得到响应。现在,我使用外部振荡器,我可以ping设备,得到一个响应,但有一个滞后。设备越长,滞后时间越长。是否有人仔细检查我的配置位和我的时钟开关,看看有没有明显的问题。
以上来自于百度翻译 以下为原文 Hello Everyone. I am using an 8MHz external oscillator to run my device. So far I have the device running. However when using USB communications I notice that there is a lag. I do not think all of my config bits are properly set. I am using a PIC24FJ256GB206. My issue here is that USB works, the PC finds the device and my USB test app can communicate with the device. I have a simple ping command. When I was using the internal clock I could ping the device very quickly and always get an immediate response. Now that I am using the external oscillator I can ping the device and get a response but there is a lag. The more I ping the device the longer the lag. Can someone double check my config bits and my clock switch to see if there are any glaring issues. // CONFIG3 #pragma config WPFP = WPFP255 // Write Protection Flash Page Segment Boundary->Highest Page (same as page 170) #pragma config SOSCSEL = EC // Secondary Oscillator Power Mode Select->External clock (SCLKI) or Digital I/O mode( #pragma config WUTSEL = LEG // Voltage Regulator Wake-up Time Select->Default regulator start-up time is used #pragma config ALTPMP = ALPMPDIS // Alternate PMP Pin Mapping->EPMP pins are in default location mode #pragma config WPDIS = WPDIS // Segment Write Protection Disable->Segmented code protection is disabled #pragma config WPCFG = WPCFGDIS // Write Protect Configuration Page Select->Last page (at the top of program memory) and Flash Configuration Words are not write-protected #pragma config WPEND = WPENDMEM // Segment Write Protection End Page Select->Protected code segment upper boundary is at the last page of program memory; the lower boundary is the code page specified by WPFP // CONFIG2 #pragma config POSCMOD = HS // Primary Oscillator Select->HS Oscillator mode is selected #pragma config IOL1WAY = ON // IOLOCK One-Way Set Enable->The IOLOCK bit (OSCCON<6>) can be set once, provided the unlock sequence has been completed. Once set, the Peripheral Pin Select registers cannot be written to a second time. #pragma config OSCIOFNC = OFF // OSCO Pin Configuration->OSCO/CLKO/RC15 functions as CLKO (FOSC/2) #pragma config FCKSM = CSECME // Clock Switching and Fail-Safe Clock Monitor->Clock switching is enabled, Fail-Safe Clock Monitor is enabled #pragma config FNOSC = PRIPLL // Initial Oscillator Select->PRIPLL #pragma config PLL96MHZ = ON // 96MHz PLL Startup Select->96 MHz PLL is enabled automatically on start-up #pragma config PLLDIV = DIV2 // 96 MHz PLL Prescaler Select->Oscillator input is divided by 2 (8 MHz input) #pragma config IESO = OFF // Internal External Switchover->IESO mode (Two-Speed Start-up) is disabled // CONFIG1 #pragma config WDTPS = PS32768 // Watchdog Timer Postscaler->1:32768 #pragma config FWPSA = PR128 // WDT Prescaler->Prescaler ratio of 1:128 #pragma config WINDIS = OFF // Windowed WDT->Standard Watchdog Timer enabled,(Windowed-mode is disabled) #pragma config FWDTEN = OFF // Watchdog Timer->Watchdog Timer is disabled #pragma config ICS = PGx1 // Emulator Pin Placement Select bits->Emulator functions are shared with PGEC1/PGED1 #pragma config GWRP = OFF // General Segment Write Protect->Writes to program memory are allowed #pragma config GCP = OFF // General Segment Code Protect->Code protection is disabled #pragma config JTAGEN = OFF // JTAG Port Enable->JTAG port is disabled // CPDIV 1:1; RCDIV FRC/1; DOZE 1:8; DOZEN disabled; ROI disabled; CLKDIV = 0x3000; // TUN Center frequency; OSCTUN = 0x0000; // CF no clock failure; NOSC PRIPLL; SOSCEN disabled; POSCEN disabled; CLKLOCK unlocked; OSWEN Switch is Complete; __builtin_write_OSCCONH((uint8_t) ((0x0300 >> _OSCCON_NOSC_POSITION) & 0x00FF)); __builtin_write_OSCCONL((uint8_t) ((0x0300 | _OSCCON_OSWEN_MASK) & 0xFF)); // Wait for Clock switch to occur while (OSCCONbits.OSWEN != 0); |
|
相关推荐
2个回答
|
|
我必须承认我从未见过如此复杂的改变时钟源的方法——你绝对确定它是在做你所期望的吗?我一直使用:而且我通常添加一个第二’while循环来检查PLL是稳定的(锁定位被设置)苏珊
以上来自于百度翻译 以下为原文 I must admit I've never seen such a complicated way to change the clock source - are you absolutely sure that it is doing what you expect? I've always used: __builtin_write_OSCCONH(0x03); // NOSC set to Primary source + PLL __builtin_write_OSCCONL(OSCCON | 0x01); // Set the OSWEN bit leaving the other bits alone Also I generally add in a 2nd 'while' loop to check that the PLL is stable (the LOCK bit is set) Susan |
|
|
|
我让我的时钟开关工作,我给出的代码是由Microchip通过代码配置器提供的。
以上来自于百度翻译 以下为原文 I got my clock switch working, the code I gave was provided by microchip though the code configurator. |
|
|
|
只有小组成员才能发言,加入小组>>
4779 浏览 9 评论
1815 浏览 8 评论
1734 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
2941 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2043 浏览 5 评论
423浏览 1评论
1101浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
345浏览 0评论
253浏览 0评论
LAN9252使用SQI通信,进行数字复位后读BYTE_TEST异常
1751浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-3-29 12:47 , Processed in 1.083928 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 深圳华秋电子有限公司
电子发烧友 (电路图) 粤公网安备 44030402000349 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号