AnsweredAssumed Answered

User button

Question asked by achour.wissem on Aug 19, 2013
Latest reply on Aug 20, 2013 by achour.wissem
hello
i'm trying to make the user button working with a simple led program here is the code and please tell me what's the problem (it worked just when i keep pushing user button then make a reset):

******************
#include "stm32f4xx.h"
#include "stm32f4_discovery.c"
#include "stm32f4xx_gpio.c"
#include "stm32f4xx_rcc.c"
#include "stm32f4xx_tim.c"
#include "misc.c"
#include "stm32f4xx_syscfg.c"
#include "stm32f4xx_exti.c"
#include "wissem.c"

int main(void)
{
 GPIO_InitTypeDef  GPIO_InitStructure;

/* GPIOD Periph clock enable */
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

  /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(GPIOD, &GPIO_InitStructure);



STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);

while(1){
 

if(STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET )
      {           
        

GPIO_WriteBit(GPIOD,GPIO_Pin_12,1); //ecrire le bit
delay_ms(1000);

GPIO_WriteBit(GPIOD,GPIO_Pin_12,0); //ecrire le bit
delay_ms(1000);

      }
   
STM_EVAL_PBGetState(BUTTON_USER);
       
    }
  }

 
   


Outcomes