Skip to main content
gu48bz
Associate II
November 1, 2006
Question

GPIO on port 2 ... what am I doing wrong?

  • November 1, 2006
  • 3 replies
  • 774 views
Posted on November 01, 2006 at 09:58

GPIO on port 2 ... what am I doing wrong?

This topic has been closed for replies.

3 replies

gu48bz
gu48bzAuthor
Associate II
May 17, 2011
Posted on May 17, 2011 at 09:33

Hi Guys,

I'm sure I'm going blind but I cannot get GPIO to work on port 2,3 or 6. The code works fine for ports 1,4,7,8 and 9. What am I doing wrong???? This is basic stuff so I'm sure I'm going daft or the ST HAL is doing me over! :D

Following Example Code will sit in a loop toggling pin 2.3 ...

{

GPIO_InitTypeDef thePortConfig;

GPIO_DeInit( GPIO2 );

thePortConfig.GPIO_Direction = GPIO_PinOutput;

thePortConfig.GPIO_Pin = GPIO_Pin_All;

thePortConfig.GPIO_Type = GPIO_Type_PushPull;

thePortConfig.GPIO_IPConnected = GPIO_IPConnected_Disable;

thePortConfig.GPIO_Alternate = GPIO_OutputAlt1;

GPIO_Init( GPIO2, &thePortConfig );

while ( TRUE )

{

GPIO_WriteBit( GPIO2, GPIO_Pin_3, Bit_SET );

GPIO_WriteBit( GPIO2, GPIO_Pin_3, Bit_RESET );

};

}

gu48bz
gu48bzAuthor
Associate II
May 17, 2011
Posted on May 17, 2011 at 09:33

Ahum... that's the one! :-] GPIO2 needs to be __GPIO2, but otherwise off it went.

Time to stick my brain on ice!

S

stefano239955_stm1_stmicro
Associate III
May 17, 2011
Posted on May 17, 2011 at 09:33

did you enable the SCU bit related to the GPIO ?

something like SCU_APBPeriphClockConfig(GPIO2 ,ENABLE);

have a look to the peripherals registers in order to

understand if the code configure the registers as in

the right way.