diff --git a/NANOVNA_STM32_F303/mcuconf.h b/NANOVNA_STM32_F303/mcuconf.h index 7fb7543..92cc42b 100644 --- a/NANOVNA_STM32_F303/mcuconf.h +++ b/NANOVNA_STM32_F303/mcuconf.h @@ -75,6 +75,12 @@ /* * RTC driver system settings for stm32f303 */ +#define RTC_PRER(a, s) ((((a) - 1) << 16) | ((s) - 1)) + +// LSE for 32768 quartz +#define STM32_RTC_LSE_PRER RTC_PRER(128, 256) +// LSI 40k +#define STM32_RTC_LSI_PRER RTC_PRER( 40, 1000) #ifndef VNA_USE_LSE // Use 40kHz LSI diff --git a/halconf.h b/halconf.h index 251afec..b3767eb 100644 --- a/halconf.h +++ b/halconf.h @@ -122,7 +122,7 @@ * @brief Enables the RTC subsystem. */ #if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) -#define HAL_USE_RTC TRUE +#define HAL_USE_RTC FALSE #endif /** diff --git a/main.c b/main.c index 293c41b..6c1dbf5 100644 --- a/main.c +++ b/main.c @@ -2890,7 +2890,12 @@ int main(void) { halInit(); chSysInit(); - + /* + * Initialize RTC library (not used ChibiOS RTC module) + */ + #ifdef __USE_RTC__ + rtc_init(); + #endif //palSetPadMode(GPIOB, 8, PAL_MODE_ALTERNATE(1) | PAL_STM32_OTYPE_OPENDRAIN); //palSetPadMode(GPIOB, 9, PAL_MODE_ALTERNATE(1) | PAL_STM32_OTYPE_OPENDRAIN); #ifdef __VNA__ diff --git a/rtc.c b/rtc.c index dc83882..80c771a 100644 --- a/rtc.c +++ b/rtc.c @@ -26,7 +26,7 @@ // Compact STM32 RTC time library #if HAL_USE_RTC == TRUE -//#error "Error VNA use self RTC lib, define HAL_USE_RTC = FALSE in halconf.h" +#error "Error VNA use self RTC lib, define HAL_USE_RTC = FALSE in halconf.h" #endif // Get RTC time as binary structure in 0x00HHMMSS