Skip to main content
jejeva
Associate
April 17, 2013
Question

f4discovery : weird gpio behavior

  • April 17, 2013
  • 14 replies
  • 2267 views
Posted on April 17, 2013 at 22:08

Hello fellow f4/stm32 Users.

I just bought a f4Discovery and i'm trying to get a grip on this great ''little'' piece of hardware.

i'm trying to do very basic things just to get a grip by reimplementing a little piece of a game i made a while ago. (basically driving leds through 595 with some microswitches as input).

Here is my problem :

i'm trying to trigger an nvic interrupt on GPIOE set like that : 

 &sharpdefine PORTBTN GPIOE

&sharpdefine RCC_AHB1Periph_PORTBTN RCC_AHB1Periph_GPIOE

&sharpdefine PLAYER1_PIN GPIO_Pin_0

&sharpdefine PLAYER2_PIN GPIO_Pin_1

&sharpdefine EXTI_PortSource_PORTBTN EXTI_PortSourceGPIOE

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_InitStructure.GPIO_Pin = PLAYER1_PIN|PLAYER2_PIN;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

GPIO_Init(PORTBTN, &GPIO_InitStructure);

interrupt setup:

 SYSCFG_EXTILineConfig(EXTI_PortSource_PORTBTN, EXTI_PinSource0|EXTI_PinSource1);

  EXTI_InitStructure.EXTI_Line = EXTI_Line0;

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;  

  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

  EXTI_Init(&EXTI_InitStructure);

  NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

but, this is provoking something strange in my hardware around the microswitches.

(the behavior is normal with the �c it was develloped for originally, namely atmega, same thing with a msp, another arm and a cypress ).

the hardware setup is (sorry image manager not working for me) : 

http://i.imgur.com/QZw4vOm.png

with all the other �c, VD between the +5 side of the resistor & iopin side is +5v is ~0v without pushing the �switch and +5 while pushing (yey pullup...)

as soon as i plug the pin in it goes +5v all the time, just like if the GPIO pins were already grounded... i didn't put any pulldown while configuring the pin so... i'm surely missing something pretty important here regarding the STM gpios....

any idea what ?

sincerely,

jege

#discovery #stm32f4 #gpio #pullup
This topic has been closed for replies.

14 replies

Tesla DeLorean
Guru
April 20, 2013
Posted on April 20, 2013 at 17:52

You understand that PE0/PE1 are connected to other components on the board, right?

PE3..15 are not connected to anything.

Make sure the clock is enabled for the GPIOE bank, that you can read/write values into the registers.
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
jejeva
jejevaAuthor
Associate
April 21, 2013
Posted on April 21, 2013 at 13:27

Hey clive, i sure understand this.

<edit>

clive, just to clear up something i wasn't really clear about,  Myboard gnd is directly connected to DiscoBard ground and i

disconnected

the gpio pins before measuring between gpiopin0 on discoboard and gnd on discoboard and after  gpiopin1 on discoboard and gnd on discoboard

these two measurements give 32 ohms in spite of the gpioeport beeing clocked and properly setup as floating inputs.

</edit>

What i don't is why, in spite of beeing setup as described sooner it's not working as documented for gpioe but is indeed working as documented for gpioc (just by changing the adressed gpio in the defines) and the interrupts fires quite correctly on press or release of the buttons.

gpioe is behaving as if i had set it up with a pull down (is 32ohms compatible with the weak pull down embedded resistor ?).

i still think there's something either wrong with gpioe on my chip or board or i missed something in the documentation that is related to this particular gpio port. that's what i'd like to know since i have to evaluate this board as a possible candidate for an embedded arm workshop i'll give next year and either document it as expected behavior ...or just as a possible default (in this case the chances are the boards we'll order will be from another batch and won't suffer from it)

jege

Tesla DeLorean
Guru
April 21, 2013
Posted on April 21, 2013 at 13:51

0690X00000605VIQAY.png
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
jejeva
jejevaAuthor
Associate
April 21, 2013
Posted on April 21, 2013 at 16:58

clive !

My hero ! i neglected to look at the board datasheet itself !

Now i understand :)

(just maybe next time indicate the doc reference, had a hard time digging this one)

thanks a bunch !

jegeva