This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Push button S2 & S3 in ARM9

Hello

I am trying to assign a function to each S2 and S3 push buttons. ( port 3.5 & 3.6 ) I want to get a display that the button S2 is pressed when it is pressed.
But i always get the message " S2 not Pressed". any ideas??

I did the following ( just the important things). These come inside the void main (void).


unsigned short Read_value2;

//*******************************
// Buttons 5 and 6 on Port 3
//*******************************

  SCU_APBPeriphClockConfig(__GPIO3,ENABLE);
  SCU_APBPeriphReset(__GPIO3,DISABLE);

  GPIO_StructInit(&GPIO_InitStruct);
  GPIO_InitStruct.GPIO_Pin= GPIO_Pin_5 | GPIO_Pin_6;
  GPIO_InitStruct.GPIO_Direction=GPIO_PinInput;
  GPIO_InitStruct.GPIO_Type=GPIO_Type_PushPull;
  GPIO_InitStruct.GPIO_IPInputConnected = GPIO_IPInputConnected_Enable;
  GPIO_Init(GPIO3,&GPIO_InitStruct);

Read_value2= GPIO_Read(GPIO3);
if ((Read_value2 && 0x20) == 0x00)// checking whether the push button is pressed
{
    lcd_clear();
    lcd_print (" S2 Pressed ");
}
else
{
lcd_clear();
lcd_print (" S2 Not pressed ");
}

Parents
  • ufff.. thnx Per Westermark!! i hv been fighting with your explanation for a while. But at last it worked. I had to make it simpler by breaking down into simpler pieces.

    Also i changed a bit from what u mentioned. I used seperate IF loops like you said but without any case structures(state machines).

    Anyway now it is working.. both buttons work and i can interrupt each other

    thnx again

Reply
  • ufff.. thnx Per Westermark!! i hv been fighting with your explanation for a while. But at last it worked. I had to make it simpler by breaking down into simpler pieces.

    Also i changed a bit from what u mentioned. I used seperate IF loops like you said but without any case structures(state machines).

    Anyway now it is working.. both buttons work and i can interrupt each other

    thnx again

Children
No data