Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem whith SW1 & SW2 on MSP430FG4618

Status
Not open for further replies.

fatma7886

Newbie level 3
Joined
Feb 28, 2010
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
electronics
Activity points
1,361
Hi,
I work on a MSP430GH4618, I find difficulties with SW1 and SW2. Indeed on the interrupt level “__interrupt void Port1_ISR (void)”, I cannot activate twice the same pushbutton successively for two different functions. For example I want support on S1 to reveal a menu then Second once on S1 to choose options among others in the menu. it carries out the code which corresponds to 2nd supports. Some said that I must return to the main program before the second supports, and others said that I must use a timer. I don’t know how to make.
I am blocked help me please
My code is the following:
//*********************************************************************************
void main(void)
{
volatile unsigned int i;

WDTCTL = WDTPW + WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP14PF; // Configure load caps

// LFXT1 startup delay
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0x47FF; i > 0; i--); // Time for flag to set
}
while (IFG1 & OFIFG); // OSCFault flag still set?
// Configuration du port P1

P1OUT = 0; // All P1.x reset
P1IES = 0x03; // P1.0, P1.1 hi/low edge
P1DIR = 0xFC; // P1.0/1 = input (switches)
P1IE |=BIT0+BIT1;

// LCD_A

LCDACTL = LCDON + LCD4MUX + LCDFREQ_128; // 4mux LCD, ACLK/128
LCDAPCTL0 = 0x7E; // Segments 4-27
P5SEL = 0x1C;
Test_LCD();
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3 w/ interrupt
}
//******************************************************************************
void Test_LCD(void)
{
}
//********************************************************************************
void bagage_1 (void)
{
}
//********************************************************************************
void yes(void)
{
}
//******************************************************************************
// PORT1 interrupt handler : traitement de l'interruption
//******************************************************************************

#pragma vector=PORT1_VECTOR
__interrupt void Port1_ISR (void)
{
volatile unsigned int i, j;

for (i = 10000; i > 0; i--); // Button debounce delay
j = 10000; // Initial delay

// si S1 et !S2
if ((!(P1IN & 0x01))&&(P1IN & 0x02))
{
yes();
if(P1IN & 0x02) baggage_1();
}

}
 

(If you do not expect P1 to change inside yes(), then) the second if is useless, and you always run either nothing, or yes() followed by baggage_1(). I suppose that the interrupt is working, and initialization its ok
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top