cancel
Showing results for 
Search instead for 
Did you mean: 

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

gu48bz
Associate II
Posted on November 01, 2006 at 09:58

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

3 REPLIES 3
gu48bz
Associate II
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 );

};

}

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.

gu48bz
Associate II
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