PIC24F32KA302 RTC配置

时间:2016-05-27 10:05:29

标签: microcontroller pic real-time-clock pic24

我想配置PIC24F32KA302的RTC,以便LED每秒切换一次。然而,它不起作用。请在我写的初始化内部RTC的RTC代码下面找到附件。 IDE:MPLAB X IDE 程序员:PICKit 3 编译:XC16

RCFGCALbits.RTCWREN = 1;
RCFGCALbits.RTCEN = 0;
while(RCFGCALbits.RTCSYNC==1);      //wait for RTCSYNC bit to become 0
ALCFGRPTbits.ALRMEN = 0;    //disable the alarm
RTCPWCbits.RTCCLK = 0;//00= External Secondary Oscillator (SOSC)
ALCFGRPTbits.AMASK = 1; //Alarm Every 1 second
ALCFGRPTbits.ARPT = 0;          //Alarm will not repeat
ALCFGRPTbits.CHIME = 0;         //Alarm CHIME Enable
ALCFGRPTbits.ALRMEN = 1 ;       //Alarm Enabled

//RTCC CONFIGURATION
RCFGCALbits.RTCOE = 0;          //RTCC output disabled
RCFGCALbits.CAL=0;              //RTC Drift Calibration
RCFGCALbits.RTCEN = 1;          //RTCC Enabled
RCFGCALbits.RTCWREN = 0;        //Disabled RTCC value write

//TODO: Investigate what this does
//PADCFG1bits.RTSECSEL = 0b11;    //RTCC Seconds Clock is not selected for the RTCC pin


//Interrupt configuration
IFS3bits.RTCIF = 0;             //Clear RTCC Alarm interrupt flag
IEC3bits.RTCIE = 1;             //RTCC Alarm interrupt Enabled

void __attribute__ ( (interrupt, no_auto_psv) )  _RTCCInterrupt(void) {
LED = ~LED;
IFS3bits.RTCIF = 0;}

我的代码有问题吗? 谢谢!

0 个答案:

没有答案