rtccreadtimedate.c
来自「基於 c51/8051 的 nand Flash Memory HY27US08」· C语言 代码 · 共 52 行
C
52 行
#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 + =
减小字号Ctrl + -
显示快捷键?