完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
亲爱的,我正在尝试使用外部电池的RTCC,不幸的是,当电源被移除时RTCC复位。我在VBAT管脚上测量了备用电池,它有很强的3.1V。我使用一个外部振荡器,它也继续工作在电池功率,并将信号发送到SCIN管脚。这是预期的工作。如果我循环电源(拔出和复制)RTCC重置。我没有关系,如果我连接程序员。在文档3905A.PDF,SECtiON57.7.2VBAT模式中,指定RTCBAT指定RTCC是否在VBAT模式下运行。默认情况下,这是真的。MPLAB代码配置不允许设置此寄存器,配置位菜单选项也不允许。pragma RTCBAT=ON或pragma RTCBAT=1被编译器忽略并生成警告。这些配置由MCC//PWCPS 1:1;PS 1:1:PWCPS 1:1;PS 1:256;CLKSEL SOSC;FDIV 0;RTCCSESESOSOSOSOSOSOSOSOSOSOSO;RTCCON2L=0;RTCCON2L=0x0030;RTCCON2L=0x0030; //DIV 63;RTCCON2H=0x0030H; //DIV 63;RTCCON2H=0x003F;//PWCSTAB 0;PWCSTAB 0;PWCSTAB 0;PWCSTAB 0;PWCSTAB 0;PWCSAMP 0 Event;PWCPOE禁用;TSBEN禁用;PWCEN禁用;WRLOCK禁用;PWCPOL禁用;TSAEN禁用;RTCOE禁用;RTCCON1L=0x8400;RTCC_Lock();//FDS#pragma配置DSWDTPS=DSWDTPS1F//深睡眠监视器定时器后置选择位->1:68719476736(25.7天)#pragma配置DSWDTOSC=LPRC//DSWDT参考时钟选择位>DSWDT使用低功耗RC振荡器(LPRC)#pragma配置DSBOREN=ON//深睡眠零功率BOR启用位>深睡眠BOR在深睡眠中启用SSWEN=ON//Deep Sleep Software Control Select Bit->Deep Sleep enabled and control of DSEN bit有人知道我的RTCC为什么重置吗?我发了很多帖子,但不知道。非常感谢。
以上来自于百度翻译 以下为原文 Dear, I'm trying to use the RTCC with an external battery, unfortunately the RTCC resets when the power is removed. I measured the backup battery on the VBAT pin, it holds a strong 3.1V. I use an external oscillator which also continues to work on battery power and send the signal to the SCIN pin. This is working as expected. If i cycle the power (unplug and replug) the RTCC resets. I doesn't matter if i connect the programmer. in document 39745a.pdf, section 56.7.2 VBAT Mode it is specified that RTCBAT specifies if the RTCC runs in VBAT mode. By default this is true. MPLab Code configuration does not allow however to set this register, neither does the configuration bit menu option. #pragma RTCBAT = ON or #pragma RTCBAT = 1 is ignored by the compiler and generates warnings. these configurations are set by MCC // PWCPS 1:1; PS 1:256; CLKSEL SOSC; FDIV 0; RTCCON2L = 0x0030; // DIV 63; RTCCON2H = 0x003F; // PWCSTAB 0; PWCSAMP 0; RTCCON3L = 0x0000; // RTCEN enabled; OUTSEL AlARM Event; PWCPOE disabled; TSBEN disabled; PWCEN enabled; WRLOCK disabled; PWCPOL disabled; TSAEN disabled; RTCOE disabled; RTCCON1L = 0x8400; RTCC_Lock(); // FDS #pragma config DSWDTPS = DSWDTPS1F // Deep Sleep Watchdog Timer Postscale Select bits->1:68,719,476,736 (25.7 days) #pragma config DSWDTOSC = LPRC // DSWDT Reference Clock Select bit->DSWDT uses Low Power RC Oscillator (LPRC) #pragma config DSBOREN = ON // Deep Sleep Zero-Power BOR Enable bit->Deep Sleep BOR enabled in Deep Sleep #pragma config DSWDTEN = ON // Deep Sleep Watchdog Timer Enable bit->DSWDT enabled #pragma config DSSWEN = ON // Deep Sleep Software Control Select Bit->Deep Sleep enabled and controlled by the DSEN bit Anybody an idea why my RTCC resets? I red a lot of post but have no idea. Thank you very much |
|
相关推荐
3个回答
|
|
我没有自己的经验与VBAT,但看看FRM手册第10.5章,默认情况下,该功能应该是积极的。我可以用我的GB406和XC16 1.26,MPLABX 3.35来重现编译器问题。这似乎是一个老问题。http://www..hip.com/for./m807725.aspxI不确定,但是您可能应该使用70005193a而不是39745a,而VBAT上的注释是相同的。从文档中,我会说,在任何情况下,你都会有一个上电复位(POR)。那你怎么知道你的RTCC重置呢?在这种情况下,您是否注意到对于重置(主功能)有不同的处理方式?您可能需要检查RCON2并执行不同的初始化。RCON和RCON2的值可能有助于查看发生了什么。
以上来自于百度翻译 以下为原文 I have no own experience with the VBAT, but looking into the FRM manual chapter 10.5, by default the feature should be active. I can reproduce the compiler problem with my GB406 and XC16 1.26, Mplabx 3.35. This seems to be an older problem. http://www.microchip.com/forums/m807725.aspx I'm not sure, but you likely should use the 70005193a instead of 39745a, while it is identical for the comment on VBAT. From the documentation I would say, that you will have a power on reset (POR) in any case. So how do you know that your RTCC resets ? Do you take care that you have different handling for the reset (main function) in this case ? You probably have to check RCON2 and perform different initialization. Also the values of RCON and RCON2 might be helpful to see whats going on. |
|
|
|
谢谢你们的建议,我能够根据你们对RTCC被重置的洞察来解决这个问题。我找到了解决方案,MCC代码总是初始化RTCC,并且不查看RTCC是否已经被初始化。在我看来,提供一个选项“保留时间”是个不错的主意,如果时间已经设置了,则不重置时间。如果在初始化之前粘贴这段代码,则只有当设备首次运行(然后设置VBPOR)或发生VBPOR事件(由于电池耗尽,RTCC值可能不正确)时,时间才会初始化。如果程序时间被定义,时间将由程序员重新编程并保留在复位上。这个函数应该在RTCC初始化之前被调用。或者,如果不想使用MCC代码,则可以通过布尔指示天气来替换RTCC_TimeReset函数,或者不需要初始化RTCC。
以上来自于百度翻译 以下为原文 Thank you rodims for your suggestion, i was able to fix the problem based on you insight that the RTCC is reset. I found the solution, the MCC code always initializes the RTCC and doesn't look if the RTCC is already initialized. It seems to me it would be a very good idea to provide an option "retain time" that does not reset the time if the time is already set. If you paste this snipped of code before the initialization the time will only initialize if the device runs for the first time (then VBPOR is set) or a VBPOR event occurs (RTCC values can be incorrect due to a drained battery). If PROGRAM_TIME is defined the time will be reprogrammed by the programmer and retained on reset. This function should be called Before the RTCC initialization. Alternatively, if you don't want to use MCC code, you can replace the RTCC_TimeReset function by a boolean indication weather or not the RTCC needs to be initialized. void check_rtcc_initialization( void ) { RTCC_TimeReset(true); //By default retain value if(RCON2bits.VBPOR) //RTCC value are not reliable { RCON2bits.VBPOR = 0; //Unset the flag RTCC_TimeReset(false); //Initialize RTCC with new value } else { #ifdef PROGRAM_TIME if(RCON2bits.VBAT) //VBAT was not connected, RTCC is wrong. VBAT = 0 after programming { RCON2bits.VBAT = 0; //Unset the flag RTCC_TimeReset(true); //No initialization needed } else { RTCC_TimeReset(false); //Initialize RTCC with new value } #endif } } |
|
|
|
感谢MaTEN-A和RodiMs-我有一个使用MCC生成的代码使用PIC24FJ128GA202的项目。我的RTCC代码很好,但是MCC控制箱没有办法保持初始化期间已经设置的时间。上面的代码是拼图的缺失部分,只需将其放到main.c中,然后在主初始化调用之前调用check_rtcc_initialization()即可。工作完美。它所做的是进行测试并设置已经定义的RTCC_TimeReset变量,如果这个变量是“true”,那么RTCC中的时间(由电池支持)将不会在正常上电时被覆盖。
以上来自于百度翻译 以下为原文 Thanks to maarten a and rodims - I have a project that uses a PIC24FJ128GA202 with code generated by MCC. My RTCC code was fine but the MCC control boxes offered no way to keep the time already set during the initialization. The code above is the missing piece to the puzzle, just drop that into main.c and then call check_rtcc_initialization() before the main initialization call. Works perfectly. What it does is make tests and set the RTCC_TimeReset variable that's already defined, if this variable is 'true' then the time in the RTCC (backed by battery) will not be overwritten on normal power up. |
|
|
|
只有小组成员才能发言,加入小组>>
5055 浏览 9 评论
1941 浏览 8 评论
1877 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3094 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2161 浏览 5 评论
603浏览 1评论
473浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
323浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
497浏览 0评论
410浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-14 00:55 , Processed in 1.182617 second(s), Total 82, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号