Hi,
I wanna implement hardware interrupt say using a switch
requirement: say I wanna presss switch n hold it for 5 seconds specinfic function is activated and press it for 10 seconds another function is generated
same switch must activate multi functions but with variable holding time of button say 5secs,10 secs,20 secs ......
ex: mp3 player has only 2 to 3 buttons but if u press it n hold it continiously then it genrates different functions in that way I want to know that
1.Do I need an external hardware for such functionality or
2.Is that enough if we can use timers n interrupt serive routines in the programm but I need some Idea to do so in programming
I m working on msp430f2274 which has high to low detection on port 1 n port 2 say if a switch is implemented on port 1.2 if I press it high to low is selected then a flag is genrated and it goes to ISR directly n executes the function as I have shown in the code below
#include "msp430x22x4.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x03;
P1OUT |= 0x00; // Set P1.0 to output direction
//P1IN |= 0x04;
P1REN |= 0x04; //Enable the Resistor otherwise the Port pin will be Floating between high n LOW states this setup is very important while using with switch.
P1IE |= 0x04; // P1.2 interrupt enabled
P1IES |= 0x04; // P1.2 Hi/lo edge
P1IFG &= ~0x04; // P1.2 IFG cleared
while(1)
{
//for(unsigned int i =0;i<600;i++)
__bis_SR_register(LPM3_bits + GIE); // Enter LPM4 w/interrupt
}}
//##########################// Port 1 interrupt service routine ###########################################################
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
for(unsigned int i =0;i<600;i++)
{P1OUT ^= 0x01; P1OUT ^= 0x002; // P1.0 = toggle
// for(unsigned int i =0;i<6000;i++);
P1IFG &= ~0x04;
for(unsigned int i =0;i<6000;i++);
} // P1.2 IFG cleared}
}
//#############################// Port 1 interrupt service routine #########################################################