AnsweredAssumed Answered

Mixing Digital inputs and Outputs on the same port.

Question asked by CS on Sep 2, 2013
Latest reply on Apr 23, 2014 by medina.edgar
Hi Folks 

I'm working with the 32F4 discovery board and I've been looking for some examples of mixed Input and output pins on the same port, however they seem a like hard to find!! I checked the Ref Manual and does seem possible to put input and output on the same port. I'm using the following setup code - is this the right way to go about it??  (the strut was declared earlier) - The outputs (3,4) seem to work fine, but I get no pull ups on the inputs....

    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; 
  GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
  GPIO_InitStruct.GPIO_Speed = GPIO_Speed_25MHz;
  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4;
  GPIO_Init(GPIOE, &GPIO_InitStruct);
  GPIO_SetBits(GPIOE, GPIO_Pin_4 );
  GPIO_SetBits(GPIOE, GPIO_Pin_3 );

  GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;  // so change the strut to from Alt funct to GPIO (in)
  GPIO_InitStruct.GPIO_Speed = GPIO_Speed_25MHz;
  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
  GPIO_Init(GPIOE, &GPIO_InitStruct);
  GPIO_SetBits(GPIOE, GPIO_Pin_0 );
  GPIO_SetBits(GPIOE, GPIO_Pin_1 );

Thanks for the time folks