2006-11-01 12:58 AM
GPIO on port 2 ... what am I doing wrong?
2011-05-17 12:33 AM
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 ); }; }2011-05-17 12:33 AM
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.2011-05-17 12:33 AM
Ahum... that's the one! :-] GPIO2 needs to be __GPIO2, but otherwise off it went.
Time to stick my brain on ice! S