Open Neutree opened 4 years ago
When set PLL0 to 832MHz with CPU set to 416MHz, get random RTC value
#include <stdio.h> #include <time.h> #include <unistd.h> #include "rtc.h" #include "entry.h" #include "sysctl.h" void get_date_time(bool alarm) { int year; int month; int day; int hour; int minute; int second; rtc_timer_get(&year, &month, &day, &hour, &minute, &second); if (!alarm) printf("%4d-%02d-%02d %02d:%02d:%02d\n", year, month, day, hour, minute, second); else printf("Alarm at --> %4d-%02d-%02d %02d:%02d:%02d\n", year, month, day, hour, minute, second); } int main(void) { printf("start\r\n"); #define FREQ_PLL0_DEFAULT 832000000UL #define FREQ_PLL1_DEFAULT 400000000UL #define FREQ_PLL2_DEFAULT 45158400UL sysctl_pll_set_freq(SYSCTL_PLL0, FREQ_PLL0_DEFAULT); // sysctl_pll_set_freq(SYSCTL_PLL1, FREQ_PLL1_DEFAULT); // sysctl_pll_set_freq(SYSCTL_PLL2, FREQ_PLL2_DEFAULT); rtc_init(); rtc_timer_set(2019,1, 1,0, 0, 0); while(1) { sleep(1); get_date_time(false); } return 0; }
kd233 or sipeed serial board
When set PLL0 to 832MHz with CPU set to 416MHz, get random RTC value
Hardware
kd233 or sipeed serial board