cancel
Showing results for 
Search instead for 
Did you mean: 

stm32F4 PB8 and PB9 GPIO problem

Tobi as
Associate II
Posted on July 10, 2018 at 15:42

Hello,

I have a problem with the pins PB8 and PB9 as GPIO. I habe used the following testcode on the EVAL324xG-EVAL Board:

int main () {

    GPIO_InitTypeDef  GPIO_InitStructure;

    RCC_AHB1PeriphClockCmd (RCC_AHB1Periph_GPIOB, ENABLE);

    GPIO_InitStructure.GPIO_Pin = (GPIO_Pin_8 | GPIO_Pin_9);

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

    GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;

    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_Init (GPIOB, &GPIO_InitStructure);

    GPIO_SetBits(GPIOB, GPIO_Pin_8);

    GPIO_SetBits(GPIOB, GPIO_Pin_9);

    while (1);

}

Both pins drive the voltage.

On the pin PB8 drives the voltage to ground. When I connect a 2k2 pullup resistor on pin PB8, then the voltage  is 2.2V.

On the pin PB9 drives the voltage to vdd. When I connect a 2k2 pulldown resistor on pin PB9, then the voltage is 1.6V.

If the MCU is in the reset state (input mode is activated), I have the same problem. I don't understand this effect.

When I configure the output type as a push-pull instead of open drain, then the MCU drives as expected the pins.

Thanks for your help!

#gpio #stm32f4
2 REPLIES 2
Posted on July 10, 2018 at 16:04

Any other circuitry connected to those pins?

Any other code running?

Read out and check/post the relevant GPIO registers' content.

JW

Tobi as
Associate II
Posted on July 11, 2018 at 08:08

I am trying to program the I2C1 interface on these pins. Of course the GPIO_Mode must be at GPIO_Mode_AF. But I have with the I2C configuration the same problem. The I2C3 with the pins PA8 and PC9 is running.

I thought maybe the EVAL-Board is defective. But the STM32F4 discovery Board also drives pin PB9 in the reset state to vdd.

The register values of GPIOB by upper code are:

MODER      = 0x0005 0280   (MODER9 = 0x1; MODER8 = 0x1)

OTYPER    = 0x0000 0300   (OT9 = 0x1; OT8 = 0x1)

OSPEEDR = 0x000a 00c0   (OSPEEDR9 = 0x2; OSPEEDR8 = 0x2)

PUPDR       = 0x0000 0100   (PUPDR9 = 0x0; PUPDR8 = 0x0)

IDR              = 0x0000 c350   (IDR9 = 0x1; IDR8 = 0x1)

ODR            = 0x0000 0300   (ODR9 = 0x1; ODR8 = 0x1)

LCKR          = 0x0000 0000   (LCK9 = 0x0; LCK8 = 0x0)

AFRL          = 0x0000 0000   (AFRL9 = 0x0; AFRL8 = 0x0)

AFRH          = 0x0000 0000   (AFRH9 = 0x0; AFRH8 = 0x0)

I mean a other function of this pins are have a higer priority as the GPIO, but I haven't found any.

Thanks for your help!