cmucam3-software (#4) - ISP Button doesn't work (#574) - Message List

ISP Button doesn't work

Hi, I'm new with CMUCam3 and I started to write a simple program that detects the button press with cc3_button_get_state() function. On the examples, only use this function to access the button and I think so that I don't need more code to use it, but it doesn't works...

But I'm reading CMUCam libraries and functions before asking here and I see this two functions (to interact with ISP button):

bool cc3_button_get_state (void)
{
  if (!_cc3_button_trigger) {
    // button has not been pressed
    return false;
  }
  // otherwise, it has been pressed, and it's in GPIO mode
  return !(REG (GPIO_IOPIN) & _CC3_BUTTON);
}
bool cc3_button_get_and_reset_trigger (void)
{
  bool result = _cc3_button_trigger;
  _cc3_button_trigger = false;
  // reset interrupt
  if (result) {
    enable_button_interrupt();
  }
  return result;
}

And it's so curious because _cc3_button_trigger is nowhere initialized, and always been false if you call cc3_button_get_and_reset_trigger().

I modify the function to put true on _cc3_button_trigger and the button works, but I don't understand why I have to modify the code.

I forget to initialize some variables? Thanks!

  • Message #1187

    Matias: Can you provide a diff? Did you just make the variable _c33_button_trigger true? I'm having the same problem and I thing its because the interrupt is not working correctly. I will have to investigate a little more. thx.

    • Message #1191

      Yes, I change the cc3_button_get_and_reset_trigger on file cc3.c (hal/lpc2106...) with this code:

      bool cc3_button_get_and_reset_trigger (void)
      {
        bool result = _cc3_button_trigger;
        _cc3_button_trigger = true;
        // reset interrupt
        if (result) {
          enable_button_interrupt();
        }
        return result;
      }
      

      It's the same, but changing button trigger at true. And in my main program, I call to this function to initialize this state, and it works.

      • Message #1196

        I believe this was caused by a bug committed in revision 600. I just reverted the code in the repository. Checkout this post:  http://www.cmucam.org/discussion/message/1189

        • Message #1234

          Thanks, I'll try it

Subscriptions