完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我在PIC18F47 J53上有一个RTCC,时间似乎没有改变。我的编译器是XC8V 1.41.My配置位如下:γ-PrimaMaungTrimg RTCOSc= T1OsCurFi也尝试了IntoClinux设置一个定时器中断来检查我的外部晶体振荡器和中断被调用。这与因特克里夫导致时钟不工作相结合导致我相信外部晶体振荡器不是问题的根源。这是我的代码来测试外部振荡器。有人能确认T1确实是使用外部晶体振荡器吗?最后,这里是测试RTCC的代码。注意:最近更新了我的代码。注意到我的RTCWRIEN落后了。时间在流逝,但还没有增加。
以上来自于百度翻译 以下为原文 I have an RTCC on a PIC18F47J53 and the time does not appear to be changing. My compiler is XC8 v 1.41. My config bits are set as follows. #pragma config RTCOSC = T1OSCREF I also tried INTOSCREF I setup a timer interrupt to check my external crystal oscillator and the interrupt is being called. That combined with the INTOSCREF causing the clock not to work leads me to believe that the external crystal oscillator is not the source of the problem. Here is my code to test the external oscillator. Can someone please confirm that T1 is indeed using the external crystal oscillator here? INTCONbits.GIE = 1; INTCONbits.PEIE = 1; T1CONbits.T1OSCEN = 1; T1CONbits.TMR1CS = 2; T1CONbits.TMR1ON = 1; PIR1bits.TMR1IF = 0; // Clear Timer 1 interrupt flag PIE1bits.TMR1IE = 1; // Enable Time 1 interrupt Finally here is the code to test the RTCC. Note: Updated my code recently. noticed my RTCWREN was backward. Time is setting but still not incrementing. T1CONbits.T1OSCEN = 1; EECON2 = 0x55; EECON2 = 0xAA; RTCCFGbits.RTCWREN = 1; RTCCFGbits.RTCEN = 1; //RTCC module is enabled RTCCFGbits.RTCOE = 0; //RTCC clock output disabled ALRMCFGbits.ALRMEN = 0; //AlARM is disabled PIE3bits.RTCCIE = 1; //RTCC Interrupt enabled PIR3bits.RTCCIF = 0; // Set minutes and seconds RTCCFGbits.RTCPTR0 = 0; RTCCFGbits.RTCPTR1 = 0; RTCVALL = 2; RTCVALH = 3; // Set hours RTCCFGbits.RTCPTR0 = 4; RTCCFGbits.RTCPTR1 = 0; RTCVALL = 0; // Set year RTCCFGbits.RTCPTR0 = 1; RTCCFGbits.RTCPTR1 = 1; RTCVALL = 5; EECON2 = 0x55; EECON2 = 0xAA; RTCCFGbits.RTCWREN = 0; INTCONbits.GIE = 1; INTCONbits.PEIE = 1; while(1) { unsigned char y; unsigned char d; unsigned char m; unsigned char w; unsigned char h; unsigned char m2; unsigned char s; unsigned char b; RTCCFGbits.RTCPTR0 = 1; RTCCFGbits.RTCPTR1 = 1; y = RTCVALL; // Get the year b = RTCVALH; // Read RTCVALH to decrement it d = RTCVALL; // Get the day m = RTCVALH; // Get the month, read decrements pointer h = RTCVALL; // Get the hours w=RTCVALH; // Get the weekday, read decrements pointer s = RTCVALL; // Get the seconds m2 = RTCVALH; //Get the minutes } |
|
相关推荐
2个回答
|
|
我在其他地方找到了这个代码。现在我需要坐下来,与我所拥有的相比。
以上来自于百度翻译 以下为原文 Got it working with this code I found elsewhere. Now I need to sit down and compare to what I have. EECON2 = 0x55; EECON2 = 0xAA; RTCCFGbits.RTCEN = 0; //Disable RTC RTCCFGbits.RTCWREN = 1; //Enable writing to RTC timer RTCCFGbits.RTCPTR0 = 1; //Set pointers before setting date RTCCFGbits.RTCPTR1 = 1; RTCVALL = 0x14; //Minutes RTCVALL = 0x1F; //Hours RTCVALL = 0x09; //Day RTCVALL = 0x00; //Year RTCCFGbits.RTCPTR0 = 1; //Set pointers before setting date RTCCFGbits.RTCPTR1 = 1; RTCVALH = 0x00; //RESERVED Always 00 RTCVALH = 0x08; //Month RTCVALH = 0x00; //Weekday RTCVALH = 0x0D; //Minutes PIE3bits.RTCCIE = 1; //RTCC Interrupt enabled PIR3bits.RTCCIF = 0; RTCCFGbits.RTCEN = 1; //Enable RTC RTCCFGbits.RTCWREN = 0; //Disable writing to RTC timer RTCCAL = 0x00; |
|
|
|
嗨,斯宾纳克,我想让它工作,我指的是PIC18F47 J53的RTCC,但我真的不知道它是如何工作的,你能和我分享你的代码吗?我真的很感激,谢谢你的回答。
以上来自于百度翻译 以下为原文 Hi, spinnaker, Im trying to make it work, I refer to RTCC of pic18f47j53, but really I dont know how it work, could you share your code with me please?, really I apreciated so much, thanks for answer me. |
|
|
|
只有小组成员才能发言,加入小组>>
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评论
531浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 23:58 , Processed in 1.276932 second(s), Total 81, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号