我使用PIC24EP512GU810,我想使用SOSC作为RTCC时钟源,SOSC连接到外部的32.768 kHz晶体。我根据参考手册设置RTCC寄存器,但RTCC不运行,时间值不变。我下载官方RTCC示例代码,它有同样的问题。我错过了什么吗?谢谢你的回复。下面是我的代码 以上来自于百度翻译 以下为原文 I use the pic24ep512gu810, I want use sosc as rtcc clock source,sosc is connected to the external 32.768kHZ crystal. I according to the reference manual to set rtcc registers,but rtcc not running, the time value never change.I download the official rtcc sample code and it has same question.Did I miss something? I will appreciate your reply. following is my code PLLFBD = 58; // M=60 CLKDIVbits.PLLPOST = 0; // N1=2 CLKDIVbits.PLLPRE = 0; // N2=2 OSCTUN = 0; // Tune FRC oscillator, if FRC is used // Disable Watch Dog Timer RCONbits.SWDTEN = 0; // Clock switching to incorporate PLL __builtin_write_OSCCONH( 0x03 ); // Initiate Clock Switch to Primary // Oscillator(XT) with PLL (NOSC=0b011) __builtin_write_OSCCONL( OSCCON || 0x01 ); // Start clock switching while( OSCCONbits.COSC != 0b011 ); // Wait for Clock switch to occur // Wait for PLL to lock while( OSCCONbits.LOCK != 1 ) { }; EnableSecOsc(); // Enable the 32.768kHz Secondary oscillator RtccInit(); // Initialise the RTCC modulevoid RtccInit( void ){ RTCCUnlock(); //unlock Timer Registers RTCCOff(); //disable the RTCC peripheral /* Configure the alarm settings*/// ALCFGRPTbits.CHIME = 0; //no rolloever of the repeat count// ALCFGRPTbits.AMASK = 0; //alarm mask configuration bits// ALCFGRPTbits.ARPT = 0; //alarm repeat counter value bits RCFGCALbits.RTCOE = 1; //enable RTCC output ANSELBbits.ANSB3 = 0; //RTCC pin pad conected to Alarm /* Load the initial values to the RTCC value registers*/ RCFGCALbits.RTCPTR = 3; //point to year register RTCVAL = 0x0010; //year RTCVAL = 0x0311; //Month & Day RTCVAL = 0x0414; //WkDay & Hour RTCVAL = 0x3710; //Min & Sec RCFGCALbits.CAL = 0x0000; //No calibration// ALCFGRPTbits.ALRMPTR = 2; //Point to Month/Day register// ALRMVAL = 0x0311; //load month & day// ALRMVAL = 0x0414; //load weekday & hour// ALRMVAL = 0x3719; //load minute & seconds ALCFGRPTbits.ALRMEN = 0; //enable the alarm// ALCFGRPTbits.ARPT = 1;// ALCFGRPTbits.AMASK = 6; RTCCOn(); //enable RTCC peripheral RTCCLock(); //lock the RTCC value registers /* Enable the RTCC interrupt*/ _RTCIF = 0; //clear the RTCC interrupt flag _RTCIP = 1; _RTCIE = 0; //enable the RTCC interrupt}
2019-03-22 07:14