cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] F722: RTC device becomes invisible after boot loader activity

I'm observing a strange phenomenon with F722 in which RTC device is left in some undefined state that it is totally invisible after boot loader activity.

When a system start to run immediately from the boot loader by means of DFU execute application request, RTC registers reads all zero and RTC is not responding to any read/write operations. The same code runs successfully on F745/F746.

A reset (hard or soft) seems to clear this state and resume normal operation until next boot loader activity.

Anyone have heard of this phenomenon?

This is a codelet that runs immediately from Reset_Handler.

    __HAL_RCC_PWR_CLK_ENABLE();
    HAL_PWR_EnableBkUpAccess();
 
    __HAL_RCC_LSI_ENABLE();
    while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) == RESET);
 
    __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI);
    __HAL_RCC_RTC_ENABLE();

This is what I see immediately after boot loading:

(gdb) p *RTC
$98 = {TR = 0, DR = 0, CR = 0, ISR = 0, PRER = 0, WUTR = 0, reserved = 0, 
  ALRMAR = 0, ALRMBR = 0, WPR = 0, SSR = 0, SHIFTR = 0, TSTR = 0, TSDR = 0, 
  TSSSR = 0, CALR = 0, TAMPCR = 0, ALRMASSR = 0, ALRMBSSR = 0, OR = 0, 
  BKP0R = 0, BKP1R = 0, BKP2R = 0, BKP3R = 0, BKP4R = 0, BKP5R = 0, BKP6R = 0, 
  BKP7R = 0, BKP8R = 0, BKP9R = 0, BKP10R = 0, BKP11R = 0, BKP12R = 0, 
  BKP13R = 0, BKP14R = 0, BKP15R = 0, BKP16R = 0, BKP17R = 0, BKP18R = 0, 
  BKP19R = 0, BKP20R = 0, BKP21R = 0, BKP22R = 0, BKP23R = 0, BKP24R = 0, 
  BKP25R = 0, BKP26R = 0, BKP27R = 0, BKP28R = 0, BKP29R = 0, BKP30R = 0, 
  BKP31R = 0}

And this is after additional soft reset:

(gdb) p *RTC
$99 = {TR = 0, DR = 8449, CR = 0, ISR = 7, PRER = 8323327, WUTR = 65535, 
  reserved = 0, ALRMAR = 0, ALRMBR = 0, WPR = 0, SSR = 0, SHIFTR = 0, 
  TSTR = 0, TSDR = 0, TSSSR = 0, CALR = 0, TAMPCR = 0, ALRMASSR = 0, 
  ALRMBSSR = 0, OR = 0, BKP0R = 1113941553, BKP1R = 0, BKP2R = 0, 
  BKP3R = 3405709037, BKP4R = 0, BKP5R = 0, BKP6R = 0, BKP7R = 0, BKP8R = 0, 
  BKP9R = 0, BKP10R = 0, BKP11R = 0, BKP12R = 0, BKP13R = 0, BKP14R = 0, 
  BKP15R = 0, BKP16R = 0, BKP17R = 0, BKP18R = 0, BKP19R = 0, BKP20R = 0, 
  BKP21R = 0, BKP22R = 0, BKP23R = 0, BKP24R = 0, BKP25R = 0, BKP26R = 0, 
  BKP27R = 0, BKP28R = 0, BKP29R = 0, BKP30R = 0, BKP31R = 12345}

5 REPLIES 5

What's the state of RCC and PWR registers, in both cases?

JW

Thanks! That was it. F722 boot loader turns off RCC_APB1ENR's RTCAPBEN. Adding call to __HAL_RCC_RTC_CLK_ENABLE() restored the access to the RTC device.

Btw, the F722 boot loader also turns off DBP in PWR, but it was taken care by HAL_PWR_EnableBkUpAccess().

Followup:

Hah! RTCAPBEN is unique to F72x. It does not exist in F74x and F75x. As H7 does have it, ST seems to have decided somewhere between F74x/F75x and F72x that RTC could be turned off.

Nice catch!

It appears to be a recent addition to the STM32s - as you've said, the older 'F74x does not have it, but the 'F767 does. Similarly, in the 'L4xx subfamily, the oldest 'L476 does not have it; newer models in both higher and lower end of the subfamily do.

Most of the STM32 that have this bit have it by default set to 1 (enabled) - the 'F72x appears to be the exception....

JW

PS. Please mark your answer as "Best"