Snippet - Use Register class to access RTC

Use Register class to access RTC

This example shows how to use Register class to set and read RTC from RTC registers on Hydra.

Dat - THanks for this. One question: the namespace you use in the code seems to indicate this might be for a Cerberus. Can you confirm it is indeed for the Hydra?


namespace CerberusRegisterAccessRamAccess

I think Dat was just using the CerberusRegisterAccessRamAccess program that I had programmed to test the Register access class that is used to access registers in all OSHW boards. My example had already set up some registers for an example. Rest assured that the code is specific to the Hydra.

Hi all,

Just as an oddity, I had to add a Thread.Sleep(1000); before setting the Date, otherwise it would not work on my hydra. I had to overload the RTC class that comes with the OSHW package.

I tried 100ms and 500ms and it didn’t work, I don’t care about the delay since I don’t write to the clock so often, and I don’t think is advisable to.

Here is the snippet:


BinaryCodedDecimalExtract(day, ref Tens, ref Ones);
                CalenderRegister |= (UInt32)((Tens << 28) | (Ones << 24));
                // Write Calender to register
                System.Threading.Thread.Sleep(1000); 
                Hydra_RTC_Registers.CALR.Write(CalenderRegister);

Hi Dat…
i found a raw code of RTC class in the codeplex.When i run that code, my code not return from this while loop
public static void RTC_Config()
{
RCC_APB1ENR.SetBits(0x10000000);
PWR_BackupAccessCmd(1);
RCC_ResetConfig();
RCC_LSEConfig(1);
while (RCC_GetFlagStatus(0x61) == 0)
{
///This loop Never fails
}

}
In that place we check the LSE is ready or not.this loop never fails, i mean never return from this loop,
And i use the 32.768 crystal with 15pf capacitors, am not use a GHI board.
Any problem with the Caps or any others.
I can able to run the RTC with the LSI …Any Help or guidance…?

@ YuvaRaja - What board are you using?

Own PCB with STM32f407VGT6.

Have you seen this codeshare ?

http://www.tinyclr.com/codeshare/entry/650

Am try that also when enter to RTC.Initialize(); method, never returns.
So only am try the raw code to initialize the RTC but still the not problem solved…

I would also check the datasheet for your MCU because it is slightly different than the one that is used on Cerb. Just to make sure that register addresses are the same. Datasheet will also tell the exact values for crystal caps.

The Cerb use the STM32f40X, so i think both my IC and cerb are same.
Tell me excatly what IC used in cerb…

Yes they are the same. Cerb is using 405 you 407. All I am suggesting is to verify that register addresses are the same which most likely is true.