Hello,
I am trying to use a double tap gesture on the BSWP panel to toggle a PWM output on/off from pin 1.2 on the CAPTIVATE-FR2633 development board. I have already been successful turning a PWM output on without using a gesture, now I am trying to add the gesture as a means of control. I used the Gesture-based capacitive touch speaker interface reference design as a template, which uses a state machine to track the user's gesture inputs. I begin by initializing the GPIO and setting up the Timer0_A module. I set bit 2 of P1OUT to low. Then the callback function for the button group is registered. If the call back registers a doubletap, then I toggle bit 2 of P1OUT to turn it on/off. The main loop then begins. So far, the if statement checking for double taps is being entered, and the relevant bit is being toggled, but I don't see any PWM output from 1.2. Curiously enough I am also only seeing button 6 registering a gesture, the other buttons don't appear to detecting gestures. Any thoughts? The relevant code is placed below.
void main(void) { // Initialize the MCU // BSP_configureMCU() sets up the device IO and clocking // The global interrupt enable is set to allow peripherals // to wake the MCU. BSP_configureMCU(); //__bis_SR_register(GIE); Demo_Init(); // Turn both LEDs to show POR activity. LED1_ON, LED2_ON; // Start the CapTIvate application CAPT_appStart(); LED1_OFF, LED2_OFF; /*** Disable watchdog timer**/ WDTCTL = WDTPW | WDTHOLD; /*** GPIO Set-Up ***/ PM5CTL0 &= ~LOCKLPM5; // Engage GPIOs P1DIR |= BIT2; //Set pin 1.2 to the output direction. P1SEL1 |= BIT2; //Select pin 1.2 as our PWM output. P1OUT &= ~BIT2; // P1.2 set LOW TA0CCR0 = 2000-1; //Set the period in the Timer A0 Capture/Compare 0 register to 2000 us. TA0CCR2 = 1000; //The period in microseconds that the power is ON. It's half the time, which translates to a 50% duty cycle. TA0CCTL2 = OUTMOD_7; // Set PWM to reset/set mode /*** Timer0_A Set-Up ***/ TA0CTL = TASSEL_2 | MC_1; //TASSEL_2 selects SMCLK as the clock source, and MC_1 tells it to count up to the value in TA0CCR0. __bis_SR_register(LPM0_bits); //Switch to low power mode 0. // Background Loop while(1) { // Run the captivate application handler. CAPT_appHandler(); CAPT_appSleep(); } }
#if USE_BUTTONGROUP==true //***************************************************************************** // // ! Button handler // ! This Handler is the callback function for this sensor and is called // ! automatically each time after the sensor is scanned. // ! Handler must first be registered as the sensor's callback. // ! See Demo_init() to see example usage. // //***************************************************************************** void keypadSensorHandler(tSensor *pSensor) { gesture_t gesture; if (FIRST_TOUCH) { LED1_ON; } else if(EXIT_TOUCH) { LED1_OFF; } gesture = processButtonGroupGesture(pSensor); // Check if valid gesture if(gesture == eNoGesture) { LED2_OFF; return; } LED2_ON; if(gesture == eDoubleTap){ P1OUT ^= BIT2; // P1.2 Toggle (PWM Output) } } #endif