完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我用MPLABX和MCC设置了PIC,并设置了如图所示的RTCC…RTCC运行,我可以显示在我的LCD下面的代码…可能会在那里,但愚蠢的论坛不会让我添加它见附件。TXT文件显示了在RTCC ISR代码中递增的半个SyxCube变量,除了它从不从零移动。很多人似乎对RTCC中断有问题。我想知道的是,当RTCC在第二个点时,我可以让LCD闪烁一个被设置的数字。有什么想法吗?
以上来自于百度翻译 以下为原文 I set up the PIC using MPLABX and MCC and set the RTCC as shown in picture... The RTCC runs and I can display on my LCD with following code... would have been there BUT STUPID FORUM WON'T LET ME ADD IT SEE ATTACHED .TXT FILE Note the half_Sec_count variable that's incremented in the RTCC ISR code except that it never moves from zero. void __attribute__ ( ( interrupt, no_auto_psv ) ) _ISR _RTCCInterrupt( void ) { /* TODO : Add interrupt handling code */ half_Sec_count++; // TM I think this is only called when an alARM is triggered but // I think I've set the alarm to trigger every half second IFS3bits.RTCIF = false; } A lot of people seem to have issues with the RTCC interrupt. What I want to do is know when the RTCC is at the half-second point so I can make the LCD blink a number that is being set. Any ideas? Attached Image(s) Attachment(s) codesnip.txt (3.02 KB) - downloaded 45 times |
|
相关推荐
14个回答
|
|
RTC中断必须启用,可能是在第二个选项卡寄存器中。
以上来自于百度翻译 以下为原文 The rtc interrupt must be enabled, maybe that is in the second tab - registers. |
|
|
|
我确信RTCC中断是启用的,在RTCC C的初始化例程的末尾有一行,表示…//启用RTCC中断IEC3BIT.RTCIE=1;但是是否也有相当于一个全局中断使能,我需要添加到Meal.C?也许这就是我丢失的图片。
以上来自于百度翻译 以下为原文 I'm pretty sure the RTCC interrupt is enabled, there's a line at the end of the initialize routine in rtcc.c that says... //Enable RTCC interrupt IEC3bits.RTCIE = 1; But is there also the equivalent to a global interrupt enable that I need to add to main.c? Maybe that's what I'm missing. Picture of second tab for RTCC in MCC attached. Attached Image(s) |
|
|
|
你读过寄存器,看看闹钟是否被设定好了吗?NVMKY必须依次设置,然后设置RTCWREN位,然后清除RTCEN位,编写寄存器,设置RTCEN位并清除RTCWRIEN位。
以上来自于百度翻译 以下为原文 Did you read back the registers to see if the alarm was actually set? The NVMKEY has to be set in sequence, followed by setting RTCWREN bit followed by clearing RTCEN bit. Write the registers, set RTCEN bit and clearing RTCWREN bit. |
|
|
|
没有全局中断标志担心,中断优先级可以改变,但默认中断将工作。
以上来自于百度翻译 以下为原文 No global interrupt flag to worry about, the interrupt priority can be changed but by default interrupts will work. |
|
|
|
似乎MCC生成的代码遵循那个顺序…但是我还没有测试是否设置了警报,也许我误解了正在发生的事情吗?我真正想要做的是知道RTCC在它的周期中的第二个点,而不必连续轮询。
以上来自于百度翻译 以下为原文 It seems that the MCC-generated code follows that sequence... void RTCC_Initialize(void) { // Set the RTCWREN bit __builtin_write_RTCWEN(); RCFGCALbits.RTCEN = 0; if(!RTCCTimeInitialized()) { // set RTCC time 2016-08-12 07-39-28 RCFGCALbits.RTCPTR = 3; // start the sequence RTCVAL = 0x16; // YEAR RTCVAL = 0x812; // MONTH-1/DAY-1 RTCVAL = 0x507; // WEEKDAY/HOURS RTCVAL = 0x3928; // MINUTES/SECONDS } // RTCOUT Alarm Pulse; PWSPRE disabled; RTCLK SOSC; PWCPRE disabled; PWCEN disabled; PWCPOL disabled; RTCPWC = 0x0000; // Enable RTCC, clear RTCWREN RCFGCALbits.RTCEN = 1; RCFGCALbits.RTCWREN = 0; //Enable RTCC interrupt IEC3bits.RTCIE = 1; } but I haven't tested to see if the alarm is set; maybe I misunderstand what is going on? What I really want to do is know when the RTCC is at the half-second point in its cycle without having to continuously poll. |
|
|
|
我开始认为这个问题可能是因为我需要定义ValualLealSeCyCube计数为易失性,否则主程序可能不会考虑ISR可以改变值。
以上来自于百度翻译 以下为原文 I beginning to think that the issue may be because I need to define the variable half_Sec_count as volatile otherwise the main program may not consider that the ISR could change the value. |
|
|
|
读回寄存器,看看它们是否已经改变。它不会阻止ISR发射和改变值。如果你正在修改这个值,那么它应该是易失的。将ISR中的值打印到UART。
以上来自于百度翻译 以下为原文 Read the registers back in and see if they have changed. It won't stop the isr from firing and changing the value. If you are modifying that value then it should be volatile. Print the value in the isr to a uart. |
|
|
|
我现在确信ISR代码根本没有被调用,我在ISR中添加了一个调用来切换一个驱动LED的输出,而没有得到任何东西,在ISR外部的相同调用切换了LED。我的ISR代码是这个。在代码前面的注释表明它必须以某种方式启用,任何想法?
以上来自于百度翻译 以下为原文 I am now certain that the ISR code isn't being called at all, I added a call into the ISR to toggle an output that drives an LED and got nothing, that same call outside the ISR toggles the LED. My ISR code is this. /* Function: void __attribute__ ( ( interrupt, no_auto_psv ) ) _ISR _RTCCInterrupt( void ) Summary: Interrupt Service Routine for the RTCC Peripheral Description: This is the interrupt service routine for the RTCC peripheral. Add in code if required in the ISR. */ void __attribute__ ( ( interrupt, no_auto_psv ) ) _ISR _RTCCInterrupt( void ) { /* TODO : Add interrupt handling code */ half_Sec_count++; IO_RB14_Toggle(); // TM I think this is only called when an alarm is triggered but // I think I've set the alarm to trigger every half second IFS3bits.RTCIF = false; } The comment that's in front of that code suggests that it has to be enabled in some way, any ideas? |
|
|
|
您可以通过手动测试来测试中断工作。IFS3BITS RTCIF=1;如果ISR不在就绪,则默认中断将重置。如我所说的,请执行RTC的寄存器转储,以查看是否做出了更改。
以上来自于百度翻译 以下为原文 You can test the interrupt works by manually firing. IFS3bits.RTCIF = 1; If the isr wasn't in place then the default interrupt is to reset. Like I said do a register dump of the rtc to see if your changes are made. |
|
|
|
我得到它的工作,正如预期的那样,我把RTCC从MCC设置,把它放回,并通过所有的设置再次,采取了合并设置,广告现在工作如预期。不确定如果我有一个设置错误或更新MCC有一个变化。谢谢你的帮助。
以上来自于百度翻译 以下为原文 I got it to work as expected, I took the RTCC out of the MCC setup, put it back in, and went through all the settings again, took the merge settings, ad now it works as expected. Not sure if I had a setting wrong or the updated MCC had a change. Thanks for the assistance though. |
|
|
|
如果你仍然有旧的MCC生成代码(这不起作用)和新代码(那么),那么把它发送到Microchip可能会很好,这样他们就可以看到MCC中是否还有(另一个)bug。苏珊
以上来自于百度翻译 以下为原文 If you still have the old MCC generated code (that doesn't work) and the new code (that does) then it might be nice to send that to Microchip so they can see if there is (yet another) bug in MCC. Susan |
|
|
|
苏珊,我没有一个版本的代码回去,但上面的RTCC寄存器值已经改变了,这就是我认为的问题。向微芯片发送东西不太可能让他们做任何我害怕的事情,我曾经在论坛上给他们的CEO写过愚蠢的过滤器,但是从来没有听说过。
以上来自于百度翻译 以下为原文 Susan, I don't have a version of the code to go back to but the rtcc register values I clipped above have changed and that was what the problem was I think. Sending stuff to Microchip is unlikely to get them to do anything I fear, I once wrote to their CEO about the stupid filter on this forum but never heard back. |
|
|
|
所以这里有一个相关的问题:我使用MCC生成的代码例程,我开始使用时间设置代码,我用RTCJBCDTimeGET(和CurrnTimeTimes)在一个时间副本中读取当前时间结构,并且我能够将它解压缩并发送到我的LCD。然后我将一年设置为不同的一年。值使用CurrnTime.tMyEng=(int)(BIN2BCD(KEYSVAL));其中KiSvar在BiNARYY中保留新的一年,然后设置RTCC UINGRTCCBCDTIMESET(和Currime),而我的第二次更新显示LCD上的新年,但星期几不改变。RTCC,我错了吗?
以上来自于百度翻译 以下为原文 So here's a related question: I'm using the MCC-generated code routines and I started to work on the time setting code, I read in a copy of the time to the currentTime structure with RTCC_BCDTimeGet(¤tTime) and I'm able to unpack it and send it to my LCD. Then I set the year to a different value using currentTime.tm_year = (int) (bin2BCD(keysVal)); where keysVal cotains the new year in binary I then set the RTCC using RTCC_BCDTimeSet(¤tTime) and my half-second update shows the new year on the LCD but the day of week is not changing. I thought the DOW would be calculated by the RTCC, am I wrong? |
|
|
|
您的代码进入道教进入RTCC。RTCC不计算DOW从年/月/日期设置。RTCC不检查您的代码输入是否与年/月/日期设置一致(反之亦然)。一旦DOW由您的代码设置,当RTCC的正常运行增加到新的一天(午夜)时,它会自动递增,戴夫。
以上来自于百度翻译 以下为原文 Your code enters the DOW into the RTCC. The RTCC does not calculate DOW from year/month/date settings. The RTCC does not check to see whether the DOW your code enters is consistent with year/month/date settings (and vice versa). Once DOW is set by your code it is automatically incremented when normally running operation of the RTCC increments to a new day (at midnight) Regards, Dave |
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2028 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3204 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
774浏览 1评论
664浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
592浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
674浏览 0评论
574浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 20:30 , Processed in 1.625116 second(s), Total 108, Slave 90 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号