cancel
Showing results for 
Search instead for 
Did you mean: 

PD0 internal pull-up working weird with PD1 internal pull-up. in stm32g071cbu MCU. Can it be an MCU internal problem?

ADovn.1
Associate II

We developed a new board with STM32G071cbu MCU which we already successfully used in our previous project.

In this project we desided to use buttons with internal MCU pull up. Buttons connection is actually very simple:

So in this configuration with pull-up, all digital inputs (PA0-1 and PD0-1) should read 1 with buttons not pressed. But it is not the case! In this question, I will write the minimum code that will lead to the problem condition (i hope that someone can compile it and check if it is the case on other boards with g071 MCUs)

Code:

#include "stm32g071xx.h"
 
int main(void)
{
 
		RCC->IOPENR |= RCC_IOPENR_GPIOAEN | RCC_IOPENR_GPIODEN;
 
 
		GPIOA->MODER &= ~0x0F; // Set PA0 and PA1 as inputs
		GPIOA->PUPDR |= 0x05;
 
		GPIOD->MODER &= ~0x0F; // Set PD0 and PD1 as inputs
		GPIOD->PUPDR |= 0x05;
 
		while(1)
		{
 
		}
}

Problem:

After downloading this code to device PA0 and PA1 are working as intended: they are high by default (around 3.3V), read high when buttons are not pressed and 0 when pressed. But there is a weird thing with port D. Setups are identical but at port D only PD1 is high (3.3V), and PD0 voltage is 0.286V (voltage is important), so PD1 is high and PD is 0 (button reads).

What happens is when I press the PD1 button it goes to 0V but PD0 is actually starting to show almost 3.3V! And then is PD1 is pressed PD0 is working properly, but when PD1 is unpressed it doesn't work. 

I checked. If either PD0 or PD1 is used as the only input with pull up, they work properly, But they don't seem to work together. I tried this code on our other stm32g071cbu board an result was the same (there were no buttons but when both PD0 and PD1 are set as digital inputs with pull UP PD1 has 3.3V and PD0 has the same 0.286V!).

Can this be some software/setup mistake that i'm not aware of, or can it be STM32G071CMU MCU hardware problem?

1 ACCEPTED SOLUTION
5 REPLIES 5
KnarfB
Principal III

On my NUCLEO-G071RB PD0 and PD1 are both 3.2x V with your code and nothing connected but a scope.

hth

KnarfB

S.Ma
Principal

Jan is more effective than the forum search bar 😁

It's funny, how many times you have answered the same question. It worked. Thanks a lot!

Some questions repeat quite often as they result from more or less surprising features of the individual chips.

In fact, I just faintly recalled that this might be the case and - as . said - I searched...

JW