Hello JH, thanks for your reply. Actually I checked the GPIO configuration after I reconfigured P2.6 for Timer usage, but everything stays like prior initialized (REN, DIR and so on). So far the routine works well, although I think that using the API for checking If the right CCIFG has been set, takes quite a while (I updated a lot in the code). maybe I will use the CMSIS notation to check that. Debouncing the button seems to be no problem since the first interrupt is triggered as an GPIO interrupt on a falling edge. After that I reconfigure the port as a Timerr CCInput on rising edge (now with the default port mapping). So when it is first triggered, even if there is a debounce, it doesn't trigger a second interrupt since the Port is now a CC input. So far it works really good, but I will keep testing it, to be sure I don't need a seperate debunce routine. Here is my routine so far: /** * \brief PORT2 ISR * \author Benjamin Brammer * \date 15.07.16 * * This interrupt is triggered if BUTTON0_MSP432 or * BUTTON1_MSP432 is pressed. It either starts the button-pressed * detection routine via Timer_A1 or just sets an event marker. * IMPORTANT!! pressing BUTTON0_MSP432 and BUTTON1_MSP432 simultaneously * will result in erroneous behaviour since in both cases Timer_A0 is used * to debounce button pressing! * */ void PORT2_IRQHandler(void) { uint32_t status; status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P2); MAP_GPIO_clearInterruptFlag(GPIO_PORT_P2, status); if(status & GPIO_PIN6) { /* seting up TA0_CCI3A */ GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P2, GPIO_PIN6, GPIO_PRIMARY_MODULE_FUNCTION); /* configuring TimerA0 as BUTTON0_MSP432 detection timer */ Timer_A_initCapture(TIMER_A0_BASE, &TimerButton0CapConfig); Interrupt_enableInterrupt(INT_TA0_N); Timer_A_startCounter(TIMER_A0_BASE, TIMER_A_CONTINUOUS_MODE); } else if(status & GPIO_PIN7) { GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P2, GPIO_PIN7, GPIO_PRIMARY_MODULE_FUNCTION); /* configuring TimerA0 as BUTTON0_MSP432 detection timer */ Timer_A_initCapture(TIMER_A0_BASE, &TimerButton1CapConfig); Interrupt_enableInterrupt(INT_TA0_N); Timer_A_startCounter(TIMER_A0_BASE, TIMER_A_CONTINUOUS_MODE); } } /** * \brief Timer_A1_CapComp ISR * \author Benjamin Brammer * \date 27.07.16 * * This interrupt checks if a correct button press has * been detected. Therfore if the button is released this ISR * is triggered and compares the CCIA1 Value with the expected value * for 1 second pressing. If a true press has been detected, the * apropriate routine is executed, depending on the measurement state. * */ void TA0_N_IRQHandler(void) { uint_fast16_t timerAcaptureValue; if(TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG & Timer_A_getCaptureCompareInterruptStatus(TIMER_A0_BASE, TIMER_A_CAPTURECOMPARE_REGISTER_3, TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG)) { timerAcaptureValue = Timer_A_getCaptureCompareCount(TIMER_A0_BASE, TIMER_A_CAPTURECOMPARE_REGISTER_3); if (measureState == IDLE && (timerAcaptureValue >= BUTTON_PRESS_COUNT)) { measureState = INIT; BOARD_LED_MEASURE_START_ON; Timer_A_stopTimer(TIMER_A0_BASE); Interrupt_disableInterrupt(INT_TA0_N); } else if (measureState == ACTIVE && (timerAcaptureValue >= BUTTON_PRESS_COUNT)) { BOARD_LED_MEASURE_STOP_ON; measureState = FINISH; Timer_A_stopTimer(TIMER_A0_BASE); Interrupt_disableInterrupt(INT_TA0_N); } else if (measureState == FINISH && (timerAcaptureValue >= BUTTON_PRESS_COUNT)) { } Timer_A_clearCaptureCompareInterrupt(TIMER_A0_BASE, TIMER_A_CAPTURECOMPARE_REGISTER_3); } else if(TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG & Timer_A_getCaptureCompareInterruptStatus(TIMER_A0_BASE, TIMER_A_CAPTURECOMPARE_REGISTER_4, TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG)) { } /* remaping P2.6 as an GPIO Input for BUTTON0_MSP432 press detection */ GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P2, GPIO_PIN6 | GPIO_PIN7); } best regards Benni
↧