Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

Are the bump switches in the TI-RSLK Kit debounced?

$
0
0

I've been working with the mentioned kit and have been trying to implement a simple LED toggle when the bump switch is pressed. When I press a bump switch, the LED toggles twice, leading me to believe they are not debounced. A simple remedy for this has been implementing a one second delay before the interrupt flag is cleared. I just want to confirm if the bump switch is not debounced.

 

 

/*
Initialize Bump sensors. Use OR logic to select multiple pins in one function call:
   Make six Port 4 pins inputs with pullup
   Select which edge for the interrupt to trigger
   Clear any possible interrupt flags
   enable GPIO interrupts for Port 4
   enable master interrupt
   pins 7,6,5,3,2,0
*/
void BumpInt_Init(void){
    GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
    
    GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P4, GPIO_PIN0 | GPIO_PIN2 |
        GPIO_PIN3 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7);
    
    GPIO_interruptEdgeSelect(GPIO_PORT_P4, GPIO_PIN0 | GPIO_PIN2 |
        GPIO_PIN3 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7, GPIO_HIGH_TO_LOW_TRANSITION);
    
    GPIO_clearInterruptFlag(GPIO_PORT_P4, GPIO_PIN0 |GPIO_PIN2 |
        GPIO_PIN3 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7);
    
    GPIO_enableInterrupt(GPIO_PORT_P4, GPIO_PIN0 |GPIO_PIN2 |
        GPIO_PIN3 | GPIO_PIN5 | GPIO_PIN6 | GPIO_PIN7);
    
    Interrupt_enableInterrupt(INT_PORT4);
}


void PORT4_IRQHandler(void){
    
    uint8_t status;      //Contains current bit states of port 4
    
    
    status = GPIO_getEnabledInterruptStatus(GPIO_PORT_P4);   //Reads which bump switches were pressed
    GPIO_clearInterruptFlag(GPIO_PORT_P4, status);          //Clears interrupt flag for bump that was triggered
    
    GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0); //toggle red LED P1.0
    
}

 


Viewing all articles
Browse latest Browse all 262198

Trending Articles