cancel
Showing results for 
Search instead for 
Did you mean: 

Switching STM32F103 GPIO From Input and Output

will_luton
Associate
Posted on June 13, 2016 at 02:06

Very new to STM32 development and am not an engineer, so apologies for what is likely a very silly question.

I'm attempting to use an STM32F103 as a programmable replacement for a game cartridge ROM. When switching from read I want to disconnect from the data bus. So I have my data port setup asGPIO_Mode_AF_PP as such:

void
configure_gpio_data(
void
){
//GPIO structure used to initialize port
GPIO_InitTypeDef GPIO_InitStructure;
//Enable clock on APB2 pripheral bus
RCC_APB2PeriphClockCmd(DATACLK, ENABLE);
//Select pins to initialize
GPIO_InitStructure.GPIO_Pin = DATA;
//Select output mode
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
//Select speed
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
//Call initialization
GPIO_Init(DATAPORT, &GPIO_InitStructure);
}

And am attempting to switch with DATAPORT -> IDR and DATAPORT -> ODR. Where am I going wrong?
2 REPLIES 2
Posted on June 13, 2016 at 04:26

GPIO_Mode_IN_FLOATING

and

GPIO_Mode_Out_PP

Although it will likely be more efficient to switch modes from in/out via the peripheral registers.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
will_luton
Associate
Posted on June 13, 2016 at 05:41

Thank you, Clive1.

I had a quick search for some example code of how to change the registry, but couldn't anything. Could you provide me with an example or reference?