完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我有一个PIC32 MX795F512L在USB启动板运行在MPLABX 3.50与XC32 V1.40编译器。我正在运行一个timeJordDebug代码示例,我在这里找到了http://vi.ECe.CONELL…xAMPLE/PLBILIG/I,将C文件(如下所示)粘贴到MPLABX中。如果我跨过并到达if StimeMeNFF(!)CHECTCRTCCRUNUNIN(3),我猜时钟没有运行,0返回。不知道下一步该怎么做。请让我知道我需要做什么来让时钟运行。谢谢。
以上来自于百度翻译 以下为原文 Hello, I have a PIC32MX795F512L on a USB starter board running in MPLABX 3.50 with the XC32 v1.40 compiler. I'm running a time_date code sample that I found here https://people.ece.cornel...xamples/plib_examples/ I pasted the c file (shown below) into MPLABX. If I step through and get to the if statement if(!CheckRtccRunning(3)) , I guess the clock is not running and 0 is returned. Not sure what to try next. Please let me know what I need to do to get the clock running. Thanks #include #ifndef _RTCC #error "This example needs a PIC32MX processor with RTCC peripheral present. Aborting build!" #endif // _RTCC // local function prototypes int CheckRtccRunning(int secWait); #pragma config FPLLMUL = MUL_20, FPLLIDIV = DIV_2, FPLLODIV = DIV_1, FWDTEN = OFF #pragma config POSCMOD = HS, FNOSC = PRIPLL, FPBDIV = DIV_1 #define SYS_FREQ (80000000L) int main(void) { rtccTime tm, tm1; // time structure rtccDate dt, dt1; // date structure SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE); RtccInit(); // init the RTCC while(RtccGetClkStat()!=RTCC_CLK_ON); // wait for the SOSC to be actually running and RTCC to have its clock source // could wait here at most 32ms // when using the RtccSetTimeDate() function, the write operation is enabled if needed and then restored to the initial value // so that we don't have to worry about calling RtccWrEnable()/RtccWrDisable() functions // let's start setting the current date { // one way to do it tm.l=0; tm.sec=0x30; tm.min=0x27; tm.hour=0x14; dt.wday=2; dt.mday=0x26; dt.mon=0x06; dt.year=0x18; RtccSetTimeDate(tm.l, dt.l); } // however, much easier to do it should be: RtccSetTimeDate(0x14273000, 0x18062602); // time is MSb: hour, min, sec, rsvd. date is MSb: year, mon, mday, wday. tm1.l=RtccGetTime(); dt1.l=RtccGetDate(); // can check that the time and date are the ones we just set if(tm.hour!=tm1.hour ||tm.min!=tm1.min) { return 0; } if(dt.l!=dt1.l) // check for proper date { return 0; } // we can read the time and date in a single operation RtccGetTimeDate(&tm1, &dt1); // now that we know the RTCC clock is up and running, it's easier to start from fresh: RtccOpen(tm.l, dt.l, 0); // set time, date and calibration in a single operation // check that the RTCC is running if(!CheckRtccRunning(3)) { return 0; } // another way to see the RTCC is tunning: check the SYNC bit while(RtccGetSync()); // wait sync to be low while(!RtccGetSync()); // wait to be high while(RtccGetSync()); // wait sync to be low again // other RTCC operations // adjust the RTCC timing RtccSetCalibration(200); // value to calibrate with at each minute // enabling the RTCC output pin RtccSelectPulseOutput(1); // select the seconds clock pulse as the function of the RTCC output pin RtccSelectPulseOutput(0); // select the alARM pulse as the function of the RTCC output pin RtccOutputEnable(1); // enable the Output pin of the RTCC return 1; } int CheckRtccRunning(int secWait) { #define WAIT_FOR_SEC_TMO 1100 // how many ms to wait for the RTCC seconds count to change rtccTime t0, t1; int fail; int secCnt; unsigned int tStart; for(secCnt=0, fail=0; secCnt tStart=ReadCoreTimer(); t0.l=RtccGetTime(); do { t1.l=RtccGetTime(); }while((t1.sec==t0.sec) && (ReadCoreTimer()-tStart)<(SYS_FREQ/2000)*WAIT_FOR_SEC_TMO); // wait seconds change if(t1.sec==t0.sec) { fail=1; break; // failed } } return !fail; } |
|
相关推荐
2个回答
|
|
你安装了一个32千赫晶体(在Y3上的董事会)?SoSC不能没有它,RTCC需要SOSC。我不会对代码本身进行评论,更不用说在主体()的末尾出现了一个明显的错误:选择报警输出到RTCC PIN,并贬低绝对的ASIT返回语句。底线:首先得到SOSC RU。尊敬的戴夫
以上来自于百度翻译 以下为原文 Have you installed a 32 kHz crystal (at Y3 on the board)? SOSC can't run without it, and the RTCC requires SOSC. I won't comment on the code itself other than to mention there is a glaring error near the end of main() that selects the alarm output to go to the RTCC pin and to disparage the absolutely asinine return statements. Bottom line: First get SOSC running. Regards, Dave |
|
|
|
嗨,戴夫,没有水晶,谢谢你的帮助。
以上来自于百度翻译 以下为原文 Hi Dave, There is no crystal. Thanks for the help. |
|
|
|
只有小组成员才能发言,加入小组>>
5284 浏览 9 评论
2056 浏览 8 评论
1968 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3231 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2277 浏览 5 评论
820浏览 1评论
709浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
652浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
710浏览 0评论
605浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-12 09:00 , Processed in 1.241724 second(s), Total 79, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号