2019-12-03 06:44 AM
I'm using STM32G441KBTx and currently have PB4 as an input and PA10 as a separate output.
First, if I put only the microcontroller and programming header, put PB4 as an input with a pullup, and configured PA10 as an output. This is what my main looks like:
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
volatile int e;
while (1)
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, 0);
HAL_Delay(10);
e = HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4);
e=-1;
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, 1);
HAL_Delay(10);
e = HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4);
e=-1;
}
}
The e=-1; lines are only to give me good places to put breakpoints and check the values of e. at first, this would only give 0, which is clearly not correct.
I added an external pullup to 3.3V at PB4, which resulted in e always being 1. I measured the voltage at PB4 and it was 3.3 at both breakpoints.
Only other line I changed in the code was line 182 of main.c where I changed
GPIO_InitStruct.Pull = GPIO_PULLUP;
to
GPIO_InitStruct.Pull = GPIO_NOPULL;
After that I measured the voltage at PB4 with multimeter again, in the first breakpoint it gives 3.3V, but at the second breakpoint it gives 2.7V.
My project including this code is attached.
In this case it still works, but in the actual use case I have 33k ohm input impedance to a 3.3V signal, which results in the read being the opposite of whatever PA10 is set too when the input is high.