Main Site Documentation

Snippet - Use Register class to access RTC


#1

Use Register class to access RTC

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


#2

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


#3

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.


#4

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);

#5

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…?


#6

@ YuvaRaja - What board are you using?


#7

Own PCB with STM32f407VGT6.


#8

Have you seen this codeshare ?

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


#9

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…


#10

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.


#11

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


#12

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.