2024-10-13 10:14 PM
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
Solved! Go to Solution.
2024-10-13 10:56 PM
2024-10-13 10:56 PM
This is consequence of USB-C PD dead-battery support.
JW
2024-10-13 11:13 PM
Thank you for your pointer. Then it is funny enough that I tried on C031C6 and get identical observation?
Rgds
Calvin
2024-10-13 11:40 PM
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
2024-10-13 11:45 PM
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
2024-10-13 11:59 PM
@waclawek.jan wrote:This is consequence of USB-C PD dead-battery support.
JW
Just my luck, i recommended the G071 to the EE team as it has the basics of what we need. I'll have to check at work if i'm using pins that could be affected and add the fix to the project code. Thanks for the link @waclawek.jan . .
2024-10-14 12:14 AM
@Chan.Calvin wrote: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.
2024-10-14 12:19 AM
Thanks.
I have just re-checked on C031, and it does not show this problem.
May be I mixed up with my target board of STM32G070, and nucleo STM32G071.
Rgds
Calvin