Skip to main content
Chan.Calvin
Associate III
October 14, 2024
Solved

Odd observation on STM32G071 device

  • October 14, 2024
  • 2 replies
  • 1594 views

Hi all

STM32CubeIDE v1.16.1

firmware package: cube FW_C0 V1.2.0

I use the IDE to start a new project with STM32G071 on its discovery board.

Just simply configure PD0, 1, 2, and 3 as inputs with pull-ups.  All other aspects are using IDE defaults.

code generated either using HAL or LL, and in the main while (1) loop just put a couple of __NOP() ; calls.

Nothing are connected externally.

Set breakpoint in mainloop __NOP() call, I am expecting PD_IDR should have pin 0 - 3 all at 1  (value 0xF), but funny enough, PD_IDR has value 0x0a.

In fact, this is observed after MX_GPIO_Init is called.

void MX_GPIO_Init(void)

{

 

GPIO_InitTypeDef GPIO_InitStruct = {0};

 

/* GPIO Ports Clock Enable */

__HAL_RCC_GPIOD_CLK_ENABLE();

 

/*Configure GPIO pins : PD0 PD1 PD2 PD3 */

GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3;

GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = GPIO_PULLUP;

HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

 

}

Also with LL code generation, single step tracing gives

initialization of PD0 gives correct observation

then initialization of PD1 put PD0 to 0, while PD1 to 1

then initialization of PD2 gives correct observation

then initialization of PD3 put PD2 to 0, while PD3 to 1

thus the outcome of PD_IDR valued as (0xA).

void MX_GPIO_Init(void)

{

 

LL_GPIO_InitTypeDef GPIO_InitStruct = {0};

 

/* GPIO Ports Clock Enable */

LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOD);

 

/**/

GPIO_InitStruct.Pin = LL_GPIO_PIN_0;

GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;

LL_GPIO_Init(GPIOD, &GPIO_InitStruct);

 

/**/

GPIO_InitStruct.Pin = LL_GPIO_PIN_1;

GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;

LL_GPIO_Init(GPIOD, &GPIO_InitStruct);

 

/**/

GPIO_InitStruct.Pin = LL_GPIO_PIN_2;

GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;

LL_GPIO_Init(GPIOD, &GPIO_InitStruct);

 

/**/

GPIO_InitStruct.Pin = LL_GPIO_PIN_3;

GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;

LL_GPIO_Init(GPIOD, &GPIO_InitStruct);

 

}

 

I also tried on STM32C031 discovery, and it has identical observation.

Is there any area I missed out in the setup to cause this issue.

Anyone comes across this?

 

Rgd

 

Calvin

 

 

Best answer by waclawek.jan

This is consequence of USB-C PD dead-battery support.

JW

2 replies

waclawek.jan
waclawek.janBest answer
Super User
October 14, 2024

This is consequence of USB-C PD dead-battery support.

JW

Chan.Calvin
Associate III
October 14, 2024

@JW_it 

Thank you for your pointer.  Then it is funny enough that I tried on C031C6 and get identical observation?

 

Rgds

Calvin

waclawek.jan
Super User
October 14, 2024

Well, that's weird, as the 'C0 is not supposed to have the USB-C PD support.

What hardware is this? Can you post a foto of the chip?

The 5k1 resistor can be measured between PD0-GND and PD2-GND when the chip is powered down (provided there is a logic 1 at PD1/PD3 - with some multimeters, it's enough to short PD0+PD1 with the meter's positive terminal, others don't supply enough voltage). Can you try on both chips?

JW

Chan.Calvin
Associate III
October 14, 2024

@JW_it

By the way, I am using nucleo board. nucleo-c031c6. 

As a matter of fact, I am using nucleo all the way, and not discovery as mentioned before.

 

The C031 may be carrying the gotcha from G0.

 

Rgds

 

Calvin

Karl Yamashita
Principal
October 14, 2024

@Chan.Calvin wrote:

@JW_it

By the way, I am using nucleo board. nucleo-c031c6. 

As a matter of fact, I am using nucleo all the way, and not discovery as mentioned before.

 

The C031 may be carrying the gotcha from G0.

 

Rgds

 

Calvin


I have both Nucleo boards.

The Nucleo-C031C6 does not have that issue like the Nucleo-G071RB does, as it doesn't have the UCPDx peripheral.   

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source