Hello,
I'm using the eZ430-Chronos watch and the EM430F6137RF900 board. I took the example code from the board and modified it. First I tried to get the acceleration data from the watch and after that sending a message to the board. This seems to work. But now I'd like to be able to recognize button presses. So if a button1 is pressed the message to be send would be modified before sending. And when the button2 is pressed I'd like to show a number on the display. The problem is when I press a button the watch freezes and I can't to anything. First I had a for-loop (for debouncing the buttonpress) in the ISR and at that point the watch stopped working after the second or third button press. When I replaced the for-loop with my wait-function the watch stopped working when I pushed the button for the Linkto-function (freeze after first press). I found something similar to my problem http://e2e.ti.com/support/low_power_rf/f/156/t/16924.aspx but looking at the code and the schematics I realized that the RF stuff does not use the port2 on my hw. So my best guess is that my ISR or the wait/delay function is really bad. I'm not that experienced in µC programming so any help/hint is welcomed.
here is the code http://pastebin.com/PEBszddd
Dait,
Are you able to set a break point and follow the flow inside the ISR?
Also, your other option is to poll teh GPIO pin such as:
#define BUTTONS_IN (P2IN)
#define BUTTON_RDOWN_PIN (BIT0)
#define BUTTON_RUP_PIN (BIT4)
#define BUTTON_LUP_PIN (BIT2)
#define BUTTON_LDOWN_PIN (BIT1)
#define BUTTON_RDOWN_IS_PRESSED ((BUTTONS_IN & BUTTON_RDOWN_PIN) == BUTTON_RDOWN_PIN)
#define BUTTON_RUP_IS_PRESSED ((BUTTONS_IN & BUTTON_RUP_PIN) == BUTTON_RUP_PIN)
#define BUTTON_LDOWN_IS_PRESSED ((BUTTONS_IN & BUTTON_LDOWN_PIN) == BUTTON_LDOWN_PIN)
#define BUTTON_LUP_IS_PRESSED ((BUTTONS_IN & BUTTON_LUP_PIN) == BUTTON_LUP_PIN)
P2DIR &= ~BUTTON_RDOWN_PIN + BUTTON_LUP_PIN + BUTTON_LDOWN_PIN + BUTTON_RUP_PIN;
P2OUT &= ~BUTTON_RDOWN_PIN + BUTTON_LUP_PIN + BUTTON_LDOWN_PIN + BUTTON_RUP_PIN;
P2REN |= BUTTON_RDOWN_PIN + BUTTON_LUP_PIN + BUTTON_LDOWN_PIN + BUTTON_RUP_PIN;
Then you can just do an if test on the buttons.... Do a short delay, check the button again for debounce, and make your decision there.
-Jason
---------------------------------------------------------------------------------------------------------Please click the Verify Answer button on this post if it answers your question.---------------------------------------------------------------------------------------------------------
That's a nice hint, thanks.
".... Do a short delay, check the button again for debounce, and make your decision there."
Do you mean:
#pragma vector = PORT2_VECTOR __interrupt void PORT2_ISR(void) { 1. call the wait function for debounce 2. check the interrupt flags }
I think I fixed one problem. I used
if ((P2IFG & P2IE) == BIT1)
to check for the IR-Flag, but this only works if only one IFG is set.
The freeze problem is still there. It seems like SimpliciTI does not like my wait function. Cause when I use a for-loop for the debouncing it seems to work.
(using the wait function before connecting/linking to the other device it seems to work)
Is it possible that I call the wait function and while this function waits for (TA1CCTL0 & CCIFG) I press a button and the wait function is called a second time. And because the first call of this function is still waiting I get some problems?????
When the watch freezes and I press the "Pause-Button" (suspend) CCS stops at:
while(!(TA1CCTL0 & CCIFG));/* Loop till compare interrupt flag is set */
When I check the Registers (when frozen) TA1R and TA1CCR0 are both 147. But CCIFG (capture/compare interrupt flag) of TA1CCTL0 is not set ->?????