完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我使用PIC24FJ128GB202作为USB数据记录器应用程序。我已经连接了3V3VBAT。3V3VBAT还为3TC76KHz的晶体供电,为RTCC(通过二极管)的SOSC。当电路板在正常庄园中被完全供电时,时钟功能良好。当电源被移除时,晶体是。然而,仍然振荡(我已经用OSSCLILCOPE检查了这个),时钟没有继续在RTCC中进展。VBAT的电压是3.2V。当电源返回到PCB时,RTCC从主电源被从板上移除的时间继续,而不是现在的时间。读取数据表,我不需要配置任何东西,以使RTCC在使用SOSC时保持时间。我也找不到标记RTCBAT来检查这是被设置的(数据表称这应该默认设置为1)以确保VTBT启用RTCC操作。下面是我的配置代码和时钟配置从安装例程。有什么建议,我做错了什么?我肯定这很简单!如果我使用LPRC作为时钟源代替SOSC,时钟工作完美。我发现LPCR时钟源在24小时内获得或丢失了一个小时,所以我很想切换到SOSC。
以上来自于百度翻译 以下为原文 I am using the PIC24FJ128GB202 for a USB datalogger application. I have connected a 3V3 VBAT. The 3V3 VBAT also powers a 32.768KHZ crystal for the SOSC for the RTCC (through a diode). The clock functions fine when the board is fully powered up in the normal manor. When power is removed, the crystal is still oscillating (I have checked this with an osscillocscope), however, the clock does not continue to progress in the RTCC. The voltage of VBAT is 3.2V. When power is given back to the PCB the RTCC continues from the time the main power supply was removed from the board, rather than the time now. Reading the datasheets, I should not need to configure anything in order to have the RTCC keep time when using the SOSC. I also cannot find the flag RTCBAT to check this is set (the datasheet says this should be set to 1 by default) to ensure RTCC operaton with VBAT is enabled. Below is my Config code and clock configuration from the setup routine. // CONFIG4 #pragma config DSWDTPS = DSWDTPS1F // Deep Sleep Watchdog Timer Postscale Select bits (1:68719476736 (25.7 Days)) #pragma config DSWDTOSC = LPRC // DSWDT Reference Clock Select (DSWDT uses LPRC as reference clock) //#pragma config DSBOREN = ON // Deep Sleep BOR Enable bit (DSBOR Enabled) #pragma config DSBOREN = OFF // Deep Sleep BOR Enable bit (DSBOR Disabled) //#pragma config DSWDTEN = ON // Deep Sleep Watchdog Timer Enable (DSWDT Enabled) #pragma config DSWDTEN = OFF // Deep Sleep Watchdog Timer Enable (DSWDT Disabled) #pragma config DSSWEN = ON // DSEN Bit Enable (Deep Sleep is controlled by the register bit DSEN) #pragma config PLLDIV = DIVIDE2 // USB 96 MHz PLL Prescaler Select bits (Oscillator input divided by 2 (8 MHz input)) #pragma config I2C1SEL = DISABLE // Alternate I2C1 enable bit (I2C1 uses SCL1 and SDA1 pins) #pragma config IOL1WAY = OFF // PPS IOLOCK Set Only Once Enable bit (The IOLOCK bit can be set and cleared using the unlock sequence) // CONFIG3 #pragma config WPFP = WPFP127 // Write Protection Flash Page Segment Boundary (Page 127 (0x1FC00)) //#pragma config SOSCSEL = ON // SOSC Selection bits (SOSC circuit selected) #pragma config SOSCSEL = OFF // SOSC Selection bits (Digital (SCLKI) mode) #pragma config WDTWIN = PS25_0 // Window Mode Watchdog Timer Window Width Select (Watch Dog Timer Window Width is 25 percent) #pragma config PLLSS = PLL_PRI // PLL Secondary Selection Configuration bit (PLL is fed by the Primary oscillator) #pragma config BOREN = ON // Brown-out Reset Enable (Brown-out Reset Enable) #pragma config WPDIS = WPDIS // Segment Write Protection Disable (Disabled) #pragma config WPCFG = WPCFGDIS // Write Protect Configuration Page Select (Disabled) #pragma config WPEND = WPENDMEM // Segment Write Protection End Page Select (Write Protect from WPFP to the last page of memory) // CONFIG2 #pragma config POSCMD = EC // Primary Oscillator Select (External-Clock Mode Enabled) #pragma config WDTCLK = LPRC // WDT Clock Source Select bits (WDT uses LPRC) #pragma config OSCIOFCN = ON // OSCO Pin Configuration (OSCO/CLKO/RA3 functions as I/O) #pragma config FCKSM = CSDCMD // Clock Switching and Fail-Safe Clock Monitor Configuration bits (Clock switching and Fail-Safe Clock Monitor are disabled) #pragma config FNOSC = PRIPLL // Initial Oscillator Select (Primary Oscillator with PLL module (XTPLL,HSPLL, ECPLL)) #pragma config ALTRB6 = APPEND // Alternate RB6 pin function enable bit (Append the RP6/ASCL1/PMPD6 functions of RB6 to RA1 pin functions) #pragma config ALTCMPI = CxINC_RB // Alternate Comparator Input bit (C1INC is on RB13, C2INC is on RB9 and C3INC is on RA0) #pragma config WDTCMX = WDTCLK // WDT Clock Source Select bits (WDT clock source is determined by the WDTCLK Configuration bits) #pragma config IESO = ON // Internal External Switchover (Enabled) // CONFIG1 #pragma config WDTPS = PS32768 // Watchdog Timer Postscaler Select (1:32,768) #pragma config FWPSA = PR128 // WDT Prescaler Ratio Select (1:128) #pragma config WINDIS = OFF // Windowed WDT Disable (Standard Watchdog Timer) //#pragma config FWDTEN = ON // Watchdog Timer Enable (WDT enabled in hardware) #pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT enabled in hardware) #pragma config ICS = PGx1 // Emulator Pin Placement Select bits (Emulator functions are shared with PGEC1/PGED1) #pragma config LPCFG = OFF // Low power regulator control (Disabled - regardless of RETEN) #pragma config GWRP = OFF // General Segment Write Protect (Write to program memory allowed) #pragma config GCP = OFF // General Segment Code Protect (Code protection is disabled) //#pragma config JTAGEN = ON // JTAG Port Enable (Enabled) #pragma config JTAGEN = OFF // JTAG Port Enable (Diabled) // Clock Configuration // RTC NVMKEY = 0x55; // Unlock RTC registers part 1 NVMKEY = 0xAA; // Unlock RTC registers part 2 RCFGCALbits.RTCWREN = 1; // Registers can be written by user RCFGCALbits.RTCEN = 0; // Disable RTC // NVMKEY = 0x55; // NVMKEY = 0xAA; // RCFGCALbits.RTCWREN = 1; // Registers can be written by user RCFGCALbits.RTCSYNC = 0; // Registers can be read without concern of rollover ripple //RCFGCALbits.HALFSEC; // Half second status bit RCFGCALbits.RTCOE = 0; // RTCC Clock output disabled //RCFGCALbits.RTCPTR; // RTCC Value register pointer bits RCFGCALbits.CAL = 0; // Drift calibration 0 ALCFGRPTbits.ALRMEN = 0; // Disable alARM ALCFGRPTbits.CHIME = 1; // Chime is enabled. Roll over allowed. //ALCFGRPTbits.AMASK = 0; // Alarm every half second //ALCFGRPTbits.AMASK = 1; // Alarm every 1 second ALCFGRPTbits.AMASK = 2; // Alarm every 10 seconds ALCFGRPTbits.ARPT = 255; // Repeat 255 times RTCPWCbits.PWCEN = 0; // Power control is disabled //RTCPWCbits.PWCPOL //RTCPWCbits.PWCCPRE = 0; //RTCPWCbits.PWCSPRE = 0; //RTCPWCbits.RTCCLK = 1; // Clock source is LPRC RTCPWCbits.RTCCLK = 0; // Clock source is SOSC IFS3bits.RTCIF = 0; // Clear interrupt flag IPC15bits.RTCIP = 2; // Set Interrupt priority 2 IEC3bits.RTCIE = 1; // Enable Interrupt //ALCFGRPTbits.ALRMEN = 0; // Disable alarm ALCFGRPTbits.ALRMEN = 1; // Enable alarm RCFGCALbits.RTCEN = 1; // Enable RTC RCFGCALbits.RTCWREN = 0; // Registers cannot be written by user Any suggestions what I'm doing wrong? I'm sure it's something simple! If I use the LPRC as the clock source in place of the SOSC the clock works perfectly. I found the LPRC clock source to gain / lose time by up to an hour in a 24 hour period, so I'm keen to switch back to the SOSC. |
|
相关推荐
7个回答
|
|
您好,您在数据表中提到了RTCBAT位。哪一页?(我在任何地方都找不到)我认为你的解锁/锁定的实现是不正确的。请确保复制手册中列出的序列。必须在汇编程序中保证汇编指令的顺序/定时。检查32 kHz的操作,启用RTCCOLK输出并用示波器检查。这是一个糟糕的实践,因为它正在改变你试图检查的东西(有时它可能会使振荡器振荡由于探测器的能力……它不会振荡)。
以上来自于百度翻译 以下为原文 Hi, You mention about RTCBAT bit in the datasheet. which page ? (I could not find it anywhere) I think your implement of unlock / lock is incorrect. Make sure to copy the sequence in assembler as listed in the manual. It must be in assembler to garantee the sequence / timing of the assembly instructions. To check operation of 32kHz, enable the RTCclock output and check it with an oscilloscope. It is a bad pratice to ever put an osicllator probe on the 32kHz because it is changing what you try to check (sometimes it may make an oscillator oscillates thanks to the capacity of the probe...and it would not oscillate without) Regard |
|
|
|
嗨,你有没有设置SSOCN来启用二次振荡器?执行了访问RTC的序列。希望这有助于Yorky。
以上来自于百度翻译 以下为原文 Hi, Have you set SOSCEN to enable the Secondary oscillator? __builtin_write_RTCWEN() performs the sequence for accessing the RTC. Hope this assists. T Yorky. |
|
|
|
谢谢你的回复。时钟解锁程序对我有用。我能够编辑时间寄存器和设置警报。我相信关于RTCBAT的注释是在第56节RTCC外部电源控制,第24页。不是在400 +页家庭参考手册。振荡器的范围与检查只是一个快速检查,它是功能,而不是被保存在持续时间,在我的其他尝试使时钟从VBAT功能失败。我没有强迫SSOCN。我看这是自动时钟(我有点困惑与解锁序列)。时钟也用SSOC功能良好,直到我依靠VBAT。不过,也许值得一试。
以上来自于百度翻译 以下为原文 Thanks for the replies. The clock unlock sequence does work for me. I am able to edit the time registers and set alarms successfully. I believe the note about rtcbat was in the section 56 rtcc with external power control, page 24. Not in 400+ page family reference manual. The checkout of the oscillator with a scope was just a quick check that it was functional, rather than being kept on for the duration, after my other attempts at getting the clock to function from vbat failed. I've not tried forcing soscen. I read this was automatic by the clock (and I got a little confused with the unlock sequence). The clock also functions fine with sosc until I come to rely on vbat. It's perhaps worth a try though. |
|
|
|
我还发现了一个有趣的勘误表。我正在使用SOSC。但它是外部的。这意味着我能做还是不能做?我不知道内部SOSC。
以上来自于百度翻译 以下为原文 I also found an interesting errata note. I am using SOSC. But it is external. Does this mean I can or can't do it? I wasn't aware of an internal SOSC. |
|
|
|
我认为应该使用“Trac-Pracm配置”SCOSSEL= ON,但是您可能已经尝试过了。在设备内部没有晶体SOSC,但是有两种内部方法明确地告诉设备二次振荡器应该运行,除了通过启用RTC隐式之外。C Mysil
以上来自于百度翻译 以下为原文 I would think #pragma config SOSCSEL = ON should be used, but you may have tried that already. There is no internal SOSC with a crystal inside the device, but there are two internal ways to explicitly tell the device that the Secondary Oscillator shall be running, in addition to implicit by enabling RTCC Mysil |
|
|
|
RTCBAT位似乎是Microchip不希望开发人员使用的配置选项。一些数据表将此位作为配置字的一部分进行文档化,但MPLABX V3.65 IDE不提供对该位的访问。该位的默认或“擦除”状态是“1”,所以您得到了您正在寻找的行为。我确实在473页的PIC24FJ256GB412数据表DS300 10089C中找到了RTCBAT配置位,但是由于IDE不能提供使该位为“0”的方式,所以不可能使用VBAT来供电。仅在家庭参考手册中描述了DSGPR0/DSGPR1寄存器保留。在所有可能的机罩中,TeTcBAT配置控制是不可用的,因为Microchip无法使其正常工作。
以上来自于百度翻译 以下为原文 The RTCBAT bit seems to be a configuration option that Microchip does not want developers to use. Some data sheets document this bit as part of a configuration word but the MPLABX v3.65 IDE does not provide access to this bit. The default or "erased" state of this bit is '1' so you get the behavior you are seeking. I did find the RTCBAT configuration bit documented in the PIC24FJ256GB412 datasheet DS30010089C on page 473 but since the IDE does not provide a way to make this bit a '0' it is not possible to use VBAT to power only the DSGPR0/DSGPR1 register retention as described in the family reference manual. In all likely hood the RTCBAT configuration control is not available because Microchip could not get it to work properly. |
|
|
|
嗨,我在你的照片里看不到这一点。你在哪里看到的?只有PIC的勘误表可以被考虑。请注意文档:家庭参考手册(FRM)对于所有16位设备都是通用的,但是在FRM上总是存在特定的数据表,因为设备有一些变化。
以上来自于百度翻译 以下为原文 Hi, I cannot see this in the erratasheet of your PIC. Where did you see this ? Only the errata of your PIC can be considered. Please be careful with documentation : Family Reference Manual (FRM) are common to all 16 bits devices BUT specific datasheet ALWAYS prevails on FRM as there are some variations device by device. Regards |
|
|
|
只有小组成员才能发言,加入小组>>
5171 浏览 9 评论
2001 浏览 8 评论
1931 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3176 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2228 浏览 5 评论
737浏览 1评论
622浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
509浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
635浏览 0评论
532浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 00:20 , Processed in 1.999113 second(s), Total 91, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号