cancel
Showing results for 
Search instead for 
Did you mean: 

Problems using RTC_SetCounter

francesc
Associate II
Posted on April 01, 2009 at 10:18

Problems using RTC_SetCounter

6 REPLIES 6
francesc
Associate II
Posted on May 17, 2011 at 13:08

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 time

briand.myers9
Associate II
Posted on May 17, 2011 at 13:08

Seen this. My guess is that your LSE (low speed external) crystal has too high a capacitance - a very common crystal capacitance is 12.5 pF, and using this crystal will cause the problem you describe.

From the datasheet :

''To avoid exceeding the maximum value of CL1 and CL2 (15 pF) it is strongly recommended to use a resonator with a load capacitance CL ≤ 7 pF. Never use a resonator with a load capacitance of 12.5 pF.''

francesc
Associate II
Posted on May 17, 2011 at 13:08

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?

francesc
Associate II
Posted on May 17, 2011 at 13:08

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.

francesc
Associate II
Posted on May 17, 2011 at 13:08

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.

:D

francesc
Associate II
Posted on May 17, 2011 at 13:08

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?