cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CUbeMX : RTC options for STM32F1

SURLEAU.Frederic
Associate III
Posted on November 20, 2017 at 16:58

On our custom board we don't use RTC clock for time or date.

But I need to activate RTC to use Backup registers, and we use GPIOC PIN13 in mode OUTPUT_PP for leds.

With STM32CUbeMX 4.23.0 and STM32CubeF1 package 1.6.0 I have two options in Pinout :

Activate RCT with 'RTC OUT' as 'Disable' or 'No RTC OutPut'.

When 'RTC OUT' is 'Disable', in the screen  'RTC Configuration', I can't select 'No output on tamper pin' so GPIOC PIN13 can't be used.

When 'RTC OUT' is 'No RTC OutPut', in the generated code we have :hrtc.Init.OutPut = RTC_OUTPUTSOURCE_NONE; which is OK, but the initialisation of time and date uses RTC_BKP_DR1 with value 0x32f2.

So I have the choice of not beeing able to use GPIOC PIN13 or RTC_BKP_DR1.

I choosed the first Option, and then manually modify the generated code to write hrtc.Init.OutPut = RTC_OUTPUTSOURCE_NONE; 

Is there another solution ?

Is it possible to have the option 'No output on TAMPER pin' when 'RTC OUT' is 'Disable' in STM32CUbeMX ?

Regards,

Fred.

‌

‌

https://community.st.com/tags♯/?tags=rtc%20backup

‌

#stm32cubemx #stm32f103 #rtc-backup
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on February 27, 2018 at 17:18

For 1 & 2: if you check 'Activate Calendar', 0x32F2 will be written to RTC_BKP_DR1.

4. I will share your request with our STM32CubeMX team.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6
SURLEAU.Frederic
Associate III
Posted on February 27, 2018 at 10:19

Same problem with STM32CUbeMX 4.24.0 and STM32CubeF1 package 1.6.0

Amel NASRI
ST Employee
Posted on February 27, 2018 at 16:53

Hi

Surleau.Fr_d_ric

‌,

Checking from my side, I noted that:

  1. 0x32F2 is written inRTC_BKP_DR1 whenever RTC OUT is ''Disable'' or ''No RTC Output'' on Pinout tab
  2. In both cases (

    RTC OUT is

    ''

    Disable'' or ''No RTC Output''), you can set PC13 as a GPIO_Output and it is configured accordingly in the generated code

  3. In the case RTC OUT is ''No RTC Output'', hrtc.Init.OutPut = RTC_OUTPUTSOURCE_NONE. This is OK for you,

    right

    ?
  4. In the case RTC OUT is

    ''

    Disable'',hrtc.Init.OutPut = RTC_OUTPUTSOURCE_ALARM. Your request is to set it toRTC_OUTPUTSOURCE_NONE in such case.

    Right

    ?

Please note that you shouldn't use PC13 to drive a LED. This is explained in the RM0008 (page 68):

0690X00000609phQAA.png

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

SURLEAU.Frederic
Associate III
Posted on February 27, 2018 at 17:15

Hi,

1. and 2. When RTC_OUT is Disable

  • 0x32F2 is not written to RTC_BKP_DR1.
  • hrtc.Init.OutPut is set to RTC_OUTPUTSOURCE_ALARM, and even if I can

    set PC13 as a GPIO_Output, I can't use it.

Generated code for RTC_OUT Disabled :

/* RTC init function */

static void MX_RTC_Init(void)

{

    /**Initialize RTC Only

    */

  hrtc.Instance = RTC;

  hrtc.Init.AsynchPrediv = RTC_AUTO_1_SECOND;

  hrtc.Init.OutPut = RTC_OUTPUTSOURCE_ALARM;

  if (HAL_RTC_Init(&hrtc) != HAL_OK)

  {

    _Error_Handler(__FILE__, __LINE__);

  }

}

3. Yes

4. Yes, or add the choice in the combo box (in RTC Configuration).

And of course the LED is not drived directly via PC13.

Regards,

Fred.

Posted on February 27, 2018 at 17:18

For 1 & 2: if you check 'Activate Calendar', 0x32F2 will be written to RTC_BKP_DR1.

4. I will share your request with our STM32CubeMX team.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on February 27, 2018 at 17:29

Hi,

For 1 & 2 : Ok, we don't use the calendar. In our application, RTC is activated only to enable access to Backup registers.

So I was looking for a configuration with no side effect like use of RTC_BKP_DR1 for 'date' or GPIO_PC13 for 'tamper'.

Thanks,

Fred.

cmull.8
Associate

I bumped into that bug yesterday and it took me hours to find the problem.

PC13 was working then after a few changes it stopped.

Reverting to a previous version of my code didn't solve the problem!

After erasing the ic completely when uploading a .hex blink example pc13 came back to life and my previous code was also working.

The problem is that RTC configuration of pc13 seems to last if you don't completely erase the chip.

But all that came from CUBEMX that let you configure pc13 to be a gpio output and enable RTC on the same pin WITHOUT ANY WARNING !!!!!

:thumbs_down:

Also the configuration of the RTC output is split in 2 parts. One in Pinout tab/RTC/RTC OUT and one in Configuration tab/RTC.

:clockwise_vertical_arrows:

And finally the Pinout tab/RTC/RTC OUT values Disable/No RTC Output are quite confusing if you are not an expert...

CubeMx is supposed to help you if you are not an expert...

 :face_screaming_in_fear: