2009-04-01 01:18 AM
Problems using RTC_SetCounter
2011-05-17 04:08 AM
Hi.
I have used an RTC sample in my program. When I want to program the counter (set time) with the function RTC_SetCounter, I use the function RTC_WaitForLastTask before and after writing to the counter. Some times the program remains blocked in the second RTC_WatiForLastTask. I have found that in this case the 1 second interruption enters each 4 or 5 micro seconds. Any one know what can be the problem? Thanks for you time2011-05-17 04:08 AM
2011-05-17 04:08 AM
I have been making several test, and I have found that the problem is when I also call the function SetDate. The contents of the function is:
void SetDate(u8 u8_Day, u8 u8_Month, u16 u16_Year) { u32 u32_DateTimer; /* Allow access to BKP Domain */ PWR_BackupAccessCmd(ENABLE); BKP_WriteBackupRegister(BKP_DR2,u8_Month); BKP_WriteBackupRegister(BKP_DR3,u8_Day); BKP_WriteBackupRegister(BKP_DR4,u16_Year); /* Disable access to BKP Domain */ PWR_BackupAccessCmd(DISABLE); } Some one have any idea of why writing to the backup registers I have problems with the RTC?2011-05-17 04:08 AM
Thanks for your information.
I use an evaluation board from ST (STM3210E-EVAL), so I think that the crystal should be a correct one. I am looking for possible causes that, after writing an order to the RTC, makes that when calling to RTC_WaitForLastTask, it remains blocked forever. In my project I use the following peripherals: TIM2 to generate an IRQ every 1 mseg, SysTick to generate an IRQ every 10 mSeg, some Outputs ports to control LEDs, and the FSMC to control the LCD.2011-05-17 04:08 AM
Hi
Finally I have solve the problem. In the SetDate routine I called PWR_BackupAccessCmd(DISABLE), and after that, I was not able to accede to the RTC. I haven't in mind that the PWR_BackupAccessCmd(DISABLE) also disables the access to the RTC. :D2011-05-17 04:08 AM
Hi.
I have reduced the SetDate routine to: PWR_BackupAccessCmd(ENABLE); PWR_BackupAccessCmd(DISABLE); As a summary, the problem is the following. I have a program that: * Uses the 1 second interruption from the RTC. It reads the RTC counter, updates the date if the RTC counter is equal to 86399 and activates a flag to indicate that the main program can display date and time. * Displays the date and time every second. * If I activate a flag, with the debugger, I read de RTC counter and the backup registers for the date, I write again the RTC counter and I write the backup registers for the date (at this moment I don't write to those registers, I only enable and disable de backup access). Some times when I activate the flag to set date and time the program remains blocked in RTC_WaitForLastTask(), and the 1 second interruption enters every 2 o 3 microseconds. It seems that the 1 second interruptions enters continuously leaving the RTC blocked. The RTC_PRL register remains with the correct value. Any idea?