Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] RTC get wrong value in different CPU frequency #112

Open
1 task done
Neutree opened this issue Aug 27, 2020 · 0 comments
Open
1 task done

[BUG] RTC get wrong value in different CPU frequency #112

Neutree opened this issue Aug 27, 2020 · 0 comments

Comments

@Neutree
Copy link

Neutree commented Aug 27, 2020

  • BUG REPORT

When set PLL0 to 832MHz with CPU set to 416MHz, get random RTC value

image

image

#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;
}

Hardware

kd233 or sipeed serial board

@Neutree Neutree changed the title [BUG] RTC get wrong value in different frequency [BUG] RTC get wrong value in different CPU frequency Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant