cancel
Showing results for 
Search instead for 
Did you mean: 

RTC_TR and RTC_DR are not set on STM32H743

MHaji.1
Associate III

Hi,

I've used STM32CubeMX to configure my STM32H7 MCU, but RTC initial values which I set on CubeMX as default value are not set on RTC_TR and RTC_DR registers after debugging line by line when  MX_RTC_Init() is called. There is no fault reported or any hardfault..., and I've use LSI for RTC.

Please help in this simple issue which waste my time couple of days ...

Thanks.

12 REPLIES 12
MHaji.1
Associate III

Please some one help, on this topic ...

The 'H7 is an overly complicated design and I don't use it so maybe some step is different from the usual procedure for other STM32, but you are supposed to:

  • enable RTC clock in RCC
  • enable PWR clock in RCC (from reading RM0433 it appears that in 'H7 this is not necessary, as I don't see any bit in RCC registers which would accomplis this)
  • enable backup domain access by setting PWR_CR1.DBP (see Accessing the backup domain subchapter in RM0433), read back PWR_CR1 content (e.g. in debugger) to check
  • enable LSI in RCC_CSR and make sure it runs by checking the LSIRDY bit in the same register
  • in RCC_BDCR, select LSI as RTC clock in RTCSEL field and enable RTC by setting RTCEN bit; read back to confirm the settings are performed as intended (if not, you may need to reset the backup domain)
  • in RTC, you need to unlock RTC writes by writing the prescribed sequence to RTC_WPR, see RTC register write protection subchapter in RTC chapter of RM
  • enter RTC initialization mode by setting RTC_ISR.INIT=1 and waiting until RTC_ISR.INITF is set to 1 - see Calendar initialization and configuration subchapter
  • write time and date to RTC_TR and RTC_DR respectively
  • exit the initialization mode by clearing RTC_ISR.INIT

JW

Thanks for your reply,

I should add, I can read RTC_TR and RTC_DR, but their values are started always from zero each time I start my code and in the following it work properly (count time), .. It seems RTC clock works properly but the problem is where I want set these registers...

Thanks.

> their values are started always from zero each time I start my code

Do you have battery connected to VBAT pin? If not, RTC is reset whenever VDD is removed.

If date/time is reset when system reset occurs without actually removing power, then it's software issue, but I don't use Cube and can't help there.

JW

Yes, when system reset, date/Time is lost....

How we can find out removing write protection by writing 0xCA and 0x53 is done properly... Is there any other register to check for insurance?

> How we can find out removing write protection by writing 0xCA and 0x53 is done properly... Is there any other register to check for insurance?

You can't check it directly, but if it's not done properly, you won't be able to change RTC_ISR.INIT.

JW

RTC_ISR.INIT is changed... but RTC_TR value does not change...:crying_face:

> RTC_TR value does not change...

How do you check it? Do you read RTC_DR after reading RTC_TR?

JW

Once I write RTC_DR or RTC_TR, check its register on debugger just after witting, nothing changed ...

After initializing when my threads starts... I read RTC_TR and RTC_DR... It works properly but all start from zero and nothing was written on their registers.

There is something wrong here which I can not write any thing on RTC_DR and RTC_TR as initial time...