From a07e287865ddfa16a997ed000508cdc64cf72c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Sun, 3 Apr 2016 21:29:04 +0200 Subject: [PATCH] use internal RTC with our tick speed --- main.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index 24b8165..e101458 100644 --- a/main.c +++ b/main.c @@ -39,6 +39,7 @@ #include // external interrupt utilities #include // timer utilities #include // ADC utilities +#include // real time clock utilities /* own libraries */ #include "global.h" // board definitions @@ -368,6 +369,11 @@ int main(void) nvic_enable_irq(BUTTON_IRQ); // enable interrupt #endif + // setup RTC + rtc_auto_awake(RCC_LSE, 32768/TICKS_PER_SECOND-1); // ensure RTC is on, uses the 32.678 kHz LSE, and the prescale is set to our tick speed, else update backup registers accordingly + rtc_interrupt_enable(RTC_SEC); // enable RTC interrupt on "seconds" + nvic_enable_irq(NVIC_RTC_IRQ); // allow the RTC to interrupt + // generate gamma correction table (with fixed gamma value) for (uint16_t i=0; i