- This topic has 3 个回复, 2 个参与人, and was last updated 4 years, 11 months 前 by Howard.
-
作者帖子
-
十月 26, 2019 - 11:23 上午 #1946hehung参与者
使用了板载的RTC,用的例程发现时间并没有增加<!–more–>
int main(void)
{
uint32_t sec;
uint32_t currSeconds;
uint8_t index;
rtc_datetime_t date;
rtc_config_t rtcConfig;/* Board pin, clock, debug console init */
BOARD_InitPins();
BOARD_BootClockRUN();
BOARD_InitDebugConsole();
/* Init RTC */
/*
* rtcConfig.wakeupSelect = false;
* rtcConfig.updateMode = false;
* rtcConfig.supervisorAccess = false;
* rtcConfig.compensationInterval = 0;
* rtcConfig.compensationTime = 0;
*/
RTC_GetDefaultConfig(&rtcConfig);
RTC_Init(RTC, &rtcConfig);
/* Select RTC clock source */
RTC_SetClockSource(RTC);PRINTF(“RTC example: set up time to wake up an alarm\r\n”);
/* Set a start date time and start RT */
date.year = 2019U;
date.month = 10U;
date.day = 25U;
date.hour = 19U;
date.minute = 0;
date.second = 0;/* RTC time counter has to be stopped before setting the date & time in the TSR register */
RTC_StopTimer(RTC);
/* Set RTC time to default */
RTC_SetDatetime(RTC, &date);
/* Enable RTC alarm interrupt */
// RTC_EnableInterrupts(RTC, kRTC_AlarmInterruptEnable);
/* Enable at the NVIC */
// EnableIRQ(RTC_IRQn);
/* Start the RTC time counter */
RTC_StartTimer(RTC);/* This loop will set the RTC alarm */
while (1)
{
busyWait = true;
index = 0;
sec = 0;
/* Get date time */
RTC_GetDatetime(RTC, &date);/* print default time */
PRINTF(“Current datetime: %04hd-%02hd-%02hd %02hd:%02hd:%02hd\r\n”,
date.year,
date.month,
date.day,
date.hour,
date.minute,
date.second);for(int m = 0;m<10;m++)
{
for (int i = 0; i < 800000; ++i)
{
__asm(“NOP”); /* delay */
}
}
}
}下面是串口收到的时间,并没有增加,已经过了几十秒了,,还是最开始设定的时间
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00
Current datetime: 2019-10-25 19:00:00十月 28, 2019 - 11:22 上午 #1951Howard参与者板载的RTC指的是什么?芯片内部的RTC吗?请参考下面例子:
rv32m1_sdk_riscv\boards\rv32m1_vega\driver_examples\rtc
十月 28, 2019 - 9:40 下午 #1953hehung参与者就是用的这个例程,但是时间并不会增加,用的内部rtc
十月 28, 2019 - 10:45 下午 #1954Howard参与者怎么可能,你直接编译运行那个例子看看时间能不能变。然后检查一下你的代码,看看个地方有问题。
-
作者帖子
- 抱歉,回复话题必需登录。