2013-04-17 01:08 PM
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_PortSourceGPIOEGPIO_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) : 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 #pullup2013-04-17 01:14 PM
Can't OR these like this
SYSCFG_EXTILineConfig(EXTI_PortSource_PORTBTN, EXTI_PinSource0|EXTI_PinSource1);2013-04-17 01:53 PM
2013-04-17 05:12 PM
void ConfigureEXTI0_1(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/* Enable GPIOE clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
/* Enable SYSCFG clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* Configure PE0/PE1 pin as input floating */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* Connect EXTI Line0 to PE0 pin */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource0);
/* Connect EXTI Line1 to PE1 pin */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource1);
/* Configure EXTI Line0 */
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; // Or whatever
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Configure EXTI Line1 */
EXTI_InitStructure.EXTI_Line = EXTI_Line1;
EXTI_Init(&EXTI_InitStructure);
/* Enable EXTI Line0 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable EXTI Line1 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;
NVIC_Init(&NVIC_InitStructure);
}
void EXTI0_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line0) != RESET)
{
/* Clear the EXTI line 0 pending bit */
EXTI_ClearITPendingBit(EXTI_Line0);
// Do something here
}
}
void EXTI1_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line1) != RESET)
{
/* Clear the EXTI line 1 pending bit */
EXTI_ClearITPendingBit(EXTI_Line1);
// Do something here
}
}
2013-04-18 01:48 PM
Hey guys,
apparently i'm more missing something on the physical layer,i followed clyve advice and added a seond exti line for the 2nd Pin.i tryed (after poking around in gdb with openocd and finding funny values in the GPIO_InitStructure) to remove the size optimization. this solved the gpio setup problem and now, when i'm poking around the pin with my multimeter the breakpoint i have put on the IRQ handler fires up (yey, getting closer). but, even in this setting the pin seems to be ''not really floating'' but linked to vdd in some way.anyone knows the breaking value of the diode protecting the vdd in 5v compliant GPIO (schema p 186 in DM00031020.pdf (family datasheet) ) ? i might have fallen upon a chip with a weak protection diode... is this a possible cause or am i completely ''out there'' ?if you look at the schema of my circuit i posted in the 1st post i can't see any other way to explain that the voltage between the pin and the +5 side of the resistor is a +5v... gonna try tomorrow with another port entirely...2013-04-18 03:06 PM
Not sure why the need to use 5V. The 3V supply should be quite adequate.
With the resistor attached to the pin, the voltage wrt ground should be 5V, when the button makes it's connection you'll get ground, check if the switch is a normally open, or normally closed.2013-04-18 11:12 PM
Hello,
i need to use 5v because some parts in be circuit needs 5v supply and that i can't get 2 different power levels on the board (i have a 3.3v input tolerant, 5v powered componant (74hct595) that is getting the logic inputs from the stm (unshown part of the code) and distributing the logic to the rest of the board that is powered by 5v), that shouldn't matter anyway since GPIOE is supposed to be 5v tolerant.the button & pullup works a treat as long as it's not connected to the stm (works with other arm based boards), i used this board with a variety of µControllers (both ttl and cmos level), in fact this board is used as a baseline for me to evaluate different platforms in term of programming complexity to do some basic tasks, adc, interrupts, timers, spi & i²c...Insofar i'm pretty pleased with the stm for everything (but this) in term of bang for the bucks.if anyone's aware of a hardware specificity of the stm i should take into account...2013-04-18 11:42 PM
How much current had this other board been pulling ?
I suspect your wiring, especially ground, could be inadequate. Such a ground-floating effect would intensify with the current requirements of the MCU.2013-04-19 12:53 PM
worst situation the board is pulling 14mA (7x595 + 11 led + writing 1x24LC00T eeprom + button not pushed) , even with the stm it's far under the 500mA the usb can provide...
i'm really scratching my head here2013-04-20 01:39 AM
Just to make my idea more clear, I believe the stm32f4 pulls significantly more current than other MCUs you mentioned.
And I never experienced such problems with (as I guess) similiar setups.