📄 rtccreadtimedate.c
字号:
#if defined(__PIC24F__)
#include <p24Fxxxx.h>
#endif
#include "Rtcc.h"
#ifdef _TMR_RTCC_V1
/*********************************************************************
Function: void RtccReadTimeDate(rtccTimeDate* pTD)
PreCondition: None
Input: pTD - pointer to a rtccTimeDate union to store the current
time and date
Output: None
Side Effects: None
Overview: The function updates the user supplied union/structure with
the current time and date of the RTCC device.
Note: This firmware solution would consist of reading each
register twice and then comparing the two values. If the
two values match, then a rollover did not occur.
********************************************************************/
void RtccReadTimeDate(rtccTimeDate* pTD)
{
rtccTimeDate currTD;
do
{
mRtccClearRtcPtr();
mRtccSetRtcPtr(RTCCPTR_MASK_YEAR);
pTD->w[0]=RTCVAL;
pTD->w[1]=RTCVAL;
pTD->w[2]=RTCVAL;
pTD->w[3]=RTCVAL; // read the user value
mRtccClearRtcPtr();
mRtccSetRtcPtr(RTCCPTR_MASK_YEAR);
currTD.w[0]=RTCVAL;
currTD.w[1]=RTCVAL;
currTD.w[2]=RTCVAL;
currTD.w[3]=RTCVAL; // read the user value
}while(pTD->f.sec!=currTD.f.sec); // make sure you have the same sec
}
#else
#warning "Does not build on this target"
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -