AnsweredAssumed Answered

Problem with GPIO

Question asked by soares.vitor on Jul 2, 2011
Latest reply on Sep 18, 2011 by ahmed.ejaz
Hello, I try turn on and turn off a led when i press the button user1 but can not to do that, So i don´t understand my mistake.

I m using Keil with stm32_init.c, i config GPIOA.PIN1 like floating input...

the main code is:

int main (void)
{

      stm32_Init ();  

    GPIOC->BSRR =  (1 <<9);     
    GPIOC->BSRR =  (1 <<8);   

    while(1)
    {
        if (!((GPIOA->IDR & 0x0001) == 0 ))              // Check if S2 is not pressed
        { 
            GPIOC->BSRR =  (1 <<8);          
           
                  
        }
        else
        {
            if (((GPIOA->IDR & 0x0001) == 0 ))              // Check if S2 is pressed
            {            
                  GPIOC->BSRR =  (1 <<24);   
            }
           }
    }
          
                      
            
   // end while
} // end main

can help?

Outcomes