2009-07-22 08:08 PM
RTC Prescaler wont work
2011-05-17 04:18 AM
Hello,
i have a Problem configuring the RTC prescaler. This is my code: // ----------------------------- // Real Time Clock konfiguration // ----------------------------- void RTC_Configuration (void) { RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP | RCC_APB1Periph_PWR, ENABLE); // Enable PWR and BKP clocks PWR_BackupAccessCmd(ENABLE); // Allow access to Backup Registers BKP_DeInit(); // Reset Backup Domain RCC_LSEConfig(RCC_LSE_ON); while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET); // Wait till LSE is ready RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); // Select LSE as RTC Clock Source RCC_RTCCLKCmd(ENABLE); // Enable RTC Clock RTC_WaitForSynchro(); // Wait for RTC registers synchronization RTC_WaitForLastTask(); // Wait until last write operation on RTC registers has finished RTC_ITConfig(RTC_IT_SEC, ENABLE); // Enable the RTC Second RTC_WaitForLastTask(); // Wait until last write operation on RTC registers has finishe // Set RTC prescaler: set RTC period to 1sec RTC_SetPrescaler(32767); // RTC period = RTCCLK/RTC_PR = (32.768 KHz)/(32767+1) RTC_WaitForLastTask(); // Wait until last write operation on RTC registers has finished } It doesnt matter which value i give the RTC_SetPrescaler function (32767 or 2 oder 16000) the Interrupt period is allways 1.6ms. I am using an external 32,768kHz Quartz. What am i doing wrong or is there missing something? Thanks2011-05-17 04:18 AM
Try enabling RTC second interrupt after setting the prescaler.
Also, I have RTC_WaitForLastTask(); RTC_SetCounter(0); after set prescaler, the rest is the same.2011-05-17 04:18 AM
Thanks,
but i didnt help.2011-05-17 04:18 AM
I found my mistake.
I forgot to clear the RTC Second Flag in the RTC Interrupt.