cancel
Showing results for 
Search instead for 
Did you mean: 

GPIOs not functioning, what gives ?

benbb
Associate II
Posted on November 19, 2011 at 15:02

All,

I`m fairly new to the STM32 family, not new to C or other micros:

I use: Keil Lite: V4.22.22.0, 4.22a with an ST-Link, this all works and compiles etc. I can run code on my board no problem !!

Now I`m trying to do something simple, ie to toggle pins on PORTC, nothing I have tried \

so far helped. here is my code simple strait-up (not all declerations are shown):

void main(void)

{

RCC_Configuration(); 

NVIC_Configuration();

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_SetBits(GPIOC, GPIO_Pin_All);            !!!!Nothing the port pins are ALWAYS low

}

I used the EXAMPLE project as well in the Keil directory... I also tried DeInit etc....

Any suggestions ?

Also what I would like to know is that once a port is configured, how do you make changes to that port/pins without affecting the whole port structure? Will it change the whole port if I call same GPIO_Init(GPIOC, &GPIO_InitStructure) function with different pins and configurations ? Can`t find any reference to  that in the documentation
3 REPLIES 3
Posted on November 19, 2011 at 17:37

Make sure you enable the GPIOC clock.

Fill in all the fields of the GPIO Init structure.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
infoinfo989
Associate III
Posted on November 19, 2011 at 17:39

Have you turned on the clock to GPIO port C? By default (after reset) the clock is turned off.

benbb
Associate II
Posted on November 20, 2011 at 09:39

YES, that solved it

I must say I have never encountered this in the PIC`s..... 🙂 

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE ); 

That solved it, now I can get the EXTI to work...

Thanks

Ben