项目中用到了RTC模块,直接用的官方库来开发的,在使用中发现“driverlib\rtc_b.h”中Calendar的注释有一些小问题,贴上代码
- //*****************************************************************************
- //
- //! \brief Used in the RTC_B_initCalendar() function as the CalendarTime
- //! parameter.
- //
- //*****************************************************************************
- typedef struct Calendar
- {
- //! Seconds of minute between 0-59
- uint8_t Seconds;
- //! Minutes of hour between 0-59
- uint8_t Minutes;
- //! Hour of day between 0-24
- uint8_t Hours;
- //! Day of week between 0-6
- uint8_t DayOfWeek;
- //! Day of month between 0-31
- uint8_t DayOfMonth;
- //! Month between 0-11
- uint8_t Month;
- //! Year between 0-4095
- uint16_t Year;
- } Calendar;
复制代码可以发现的是:Hours 0-24,DayOfMonth 0-31,Month 0-11,有点懵呀,这好像和我们地球上正常使用的Calendar有点出入,然后翻阅Datasheet,在Family User's Guide里RTC_B的介绍中找到了答案
修正后的代码:
- typedef struct Calendar
- {
- //! Seconds of minute between 0-59
- uint8_t Seconds;
- //! Minutes of hour between 0-59
- uint8_t Minutes;
- //! Hour of day between 0-23
- uint8_t Hours;
- //! Day of week between 0-6
- Week_e DayOfWeek;
- //! Day of month between 1-31
- uint8_t DayOfMonth;
- //! Month between 1-12
- uint8_t Month;
- //! Year between 0-4095
- uint16_t Year;
- } Calendar;
复制代码
本文来自论坛,点击查看完整帖子内容。