cancel
Showing results for 
Search instead for 
Did you mean: 

Pin PC13 in input mode with pull up option does not drive the pin high.

ASank
Associate II

Hi,

I am trying to configure the pin PC13 in my STM32G473VBE6 device as Input with Pull up option.

There is a sensor connected to it, so when it is activated it will pull the pin low. But after configuring the pin PC13 to Input with pull up. I am seeing the pin in a weird state, when i scope that pin, i see a square wave with 1Hz output between 3.3V and 0.

Is there any other alternate functions with the pin PC13 that needs to be changed for it to work correctly? This is the setting i am using for that input.

 GPIO_InitStruct.Pin = GPIO_PIN_13;

 GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

 GPIO_InitStruct.Pull = GPIO_PULLUP;

 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

Thanks and Regards,

Aviinaash S

4 REPLIES 4
TDK
Guru

> STM32G473VBE6

I can't see that part anywhere. Maybe a typo?

Regardless, sounds like PC13 is acting as the RTC sync signal, which, if enabled, overrides whatever you have in the GPIO register. You must be enabling it somewhere.

See "35 Tamper and backup registers (TAMP)" in the reference manual and the RTC_CR register OUTxEN fields.

If you feel a post has answered your question, please click "Accept as Solution".

https://www.st.com/en/microcontrollers-microprocessors/stm32g474re.html

Unpack the actual register settings for RCC, GPIO and RTC at the point you observe the signal.

RTC_TS, RTC_OUT1

Also be aware that PC13 is in the lower power domain.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ASank
Associate II

Thanks for the respoinse.

Sorry for the delay, was having a long weekend here. Please find the contents of the registers

RTC_CR - COE field is 0

TAMTS - 1

TAMPOE - 0

GPIO registers

GPIOC - PUPDR13 - 0x01

IDR13 - 1

Also now I am no longer seeing that pin with square wave (no idea how it went away, nothing was changed in the code) but its always low at 0V. So a GPIO with pull up enabled should be seeing 3.3V correct?

Or the pin PC13 cannot be pulled high?

Thanks and Regards,

Aviinaash S

_dalbert
Associate III

I have periodically seen similar problems with PC13 on the STM32L051 platform.

My scenario is similar: PC13 is configured as an input with pullup (and there is an additional external 10K pull-up).

PC13 is used to detect closure of a momentary (tactile) switch closure to ground.

Once in a while, PC13 starts quickly alternating between reading a logic 1 and a logic 0 as though the switch were constantly being pressed, even though the switch is open. When this is happening, I measured ~1v on PC13. Unfortunately I checked with a multimeter but should have used a scope and will do that next time I reproduce the problem.

However, I'll bet this is the RTC issue that TDK mentioned.

When the problem manifests for me, it persists across hard resets and power cycles, but eventually clears (possibly after a longer power cycle). Once it clears, I can't reproduce it. Nowhere in the code is the RTC output being configured, but it seems likely that this is the culprit. The reference manual indicates that the RTC configuration for PC13 overrides the GPIO configuration (see 22.4.2).

The STM32L0 series is so low power that bulk capacitance on the board often keeps things in memory far longer than I'd expect after power has been removed. System Reset does not affect the RTC domain so I'm betting that the PC13 output bit gets set somehow, perhaps related to a power down not reaching 0v. I'm going to add code to look for this condition, and if found: log, alarm, then clear it.

If you figure out how this is happening on your system, I'd love to know.

ST: is there any additional information about this? For example, do user reports suggest this is related to incomplete reset of the RTC power domain, perhaps after short power outages?