This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

buttons unresponsive

I am using the following code

while(1)

{  

if(ButtonsPoll(0,0)& LEFT_BUTTON) TurnOffCone^=1;  

   

if(ButtonsPoll(0,0)& RIGHT_BUTTON) TurnOffCtwo^=1;

    }

the buttons are unresponsive so that they are not being recognized as being pressed how do I use the buttons as interrupt or fix so that the buttons are recognized as pressed right away thx

  • Hi khary,

    Did you remember to use pull-ups?

    What Board are you using?

    Are you using interrupt or just reading the state? If your just reading the state check this on the TM4C123 launchpad: https://sites.google.com/site/luiselectronicprojects/tutorials/tiva-gpio/simple-digital-input

  • I am using the buttonsinit() function. When I change a global int value there is no problem but I am having problems when I toggle the int value. the code for the int value is int TurnOffCtwo=0; then I use if(TurnOffCtwo == 1) and I toggle that value with TurnOffCtwo^=1; in order to enable or disable the write to Uart. Any ideas what I am doing wrong.

  • Hi khary,

    without virtually no code i can't say analyze anything. Please provide the full code. Use the insert code tool in the top right of the editor that looks like </>

  • here is the program that I am working on I need to figure out the unresponsive/sometime working button issue thanks.

    Chess Clock.zip
  • The code you provided doesn't initialize the the inputs in any way. The buttons.c was not present anywhere.

    Please don't try to rush a response by contacting directly by email, i am a student and the year just started, i have been to busy to analyze any kind of code and i have work of my own behind schedule.

  • this zip file has button.c in it so you should be able to run the code

    Chess Clock.zip
  • For some reason it wasn't when i unzip it. You could at least tell me in which folder it is. I am trying to help you and you seem to do very little effort to try to solve this problem.

    Try after 

     ROM_SysCtlPeripheralEnable(BUTTONS_GPIO_PERIPH);

    In the ButtonsInit, to add SysCtlDelay(3); that's the only thing that jumps into view since i have never done a debounce besides using a simple delay or timeout.

  • @Khary,

    Read your code - you need to declare and use AppButtonHandler as interrupt in startup_ccs.c file and to initialize the sysTick routine in your main file. See the qs-rgb application; it would be better to start up from this one.

    Second, in interrupts functions, there is no need to disable/enable the Master interrupt  - and btw, you failed to initialize it in your main file. Enabling/disabling is used in some real time kernels, for some reasons, but this is not the case here. More, for Cortex micros, even real time kernels avoid doing this (new technology inside micro allow this unusual feature).

    Petrei