cancel
Showing results for 
Search instead for 
Did you mean: 

RTC Clock on GPIO_Input PC13

Mongolov
Associate II

I'm currantly working on STM32G4 series and I had a problem. I initiate PC13 pin as GPIO_INPUT to read state from button. But It is possible to config this pin(PC13) such as RTC_OUT1. I config my RTC clock on Activate Clock Source to write and read actually time. When I write time to RTC I receive a clock source (1Hz) on pin PC13 and it is impossible to change it. I must turn off the device and wait a few seconds after that. I'm looked for what happend and I found that ST library(rtc library) modify registers on that way.

ST_library.png


I'm never modify registers, so I'm confused that is it mistake on library or I do something wrong?

 

* I'm config RTC from LSE (32.768kHz) frequency.

8 REPLIES 8

Do you use Cube/HAL? Do you fully initialise the initialization structs before calling the clock setup functions?

How is VBAT connected? Maybe this is consequence of VBAT brownout?

I use Cube/HAL. This is my RTC initialization.
Zrzut ekranu 2023-07-24 094239.png

There is nothing complicated. On HAL_RTC_INIT we go to library on ST. 
It is True that VBAT is connected in specific way but the voltage on VBAT is the range on 2,5 to 3,3V, but when I checked VBAT pins, thanks to osciloscope The Voltage is stable 3V. 

BTW. Thank you for this link :)

I currently commented this modifying registers and cuurently everythink working fine. But I'm not sure that changing library is a correct way, so I want to understand what happend there :)

Cube is open source, so you can debug it as any other code, to find out why does it write incorrect/unexpected values to RTC registers.

You can also place data breakpoint (a.k.a. watchpoint) to given register to find out where and what value is written to it.

JW

Ced
ST Employee

Hello @Mongolov ,

To enable the calibration output (" (1Hz) on pin PC13"), the RTC_CR_COE bit need to be enable.

In order to use the PC13 pin as standard GPIO you need to respect the condition given by the table 333. inside RM0440:

Ced_0-1690467037820.png

 

Maybe one of this condition is not ok.

 Best Regards,

Ced

Hi @Ced ,

> To enable the calibration output (" (1Hz) on pin PC13"), the RTC_CR_COE bit need to be enable.

Mongolov does *not* want to use PC13 as calibration output:

> I initiate PC13 pin as GPIO_INPUT to read state from button.

JW

Hello @waclawek.jan ,

Yes, I understand the point.

Mongolov saw '(1Hz) on pin PC13.  So, I guess that is the RTC calibration output is enabled on RTC Output 1.

And to use the PC13 as the standard GPIO Pin (GPIO_INPUT) he need to follow condition given by the table 333.

Best Regards,

Ced