AnsweredAssumed Answered

Using PH2 as GPIO

Question asked by r.juergen on Dec 4, 2013
Latest reply on Dec 4, 2013 by r.juergen
Hi,

i'm using a STM32L151VD for a little project and i want to use the Port H2 as a normal Output for SPI CS. Using another Port (e.g. PC8) all works fine, but with PH2 it does not work at all.

GPIO_InitTypeDef GPIO_InitStructure;
uint8 condition;   
// SPI CS via PH2
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_400KHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; 
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOH, &GPIO_InitStructure);
 
// Code only for debugging
GPIO_HIGH(GPIOH, GPIO_Pin_2);
condition = GPIO_ReadInputDataBit(GPIOH, GPIO_Pin_2);
GPIO_LOW(GPIOH, GPIO_Pin_2);
condition = GPIO_ReadInputDataBit(GPIOH, GPIO_Pin_2);
GPIO_HIGH(GPIOH, GPIO_Pin_2);
condition = GPIO_ReadInputDataBit(GPIOH, GPIO_Pin_2);
GPIO_LOW(GPIOH, GPIO_Pin_2);
condition = GPIO_ReadInputDataBit(GPIOH, GPIO_Pin_2);
condition = condition; // To prevent compiler warning

The var condition above is always 0 and the port is low all the time.
In the datasheet PH2 is defined as IO-Port, is that right or is it a mistake in the datasheet?
What should i keep in mind using PH2 as described?

Best regards,
Juergen

Outcomes