简体   繁体   中英

C - prevent interrupt activiation - MSP430

I wrote the following code to initialize the buttons on my MSP430 microcontroller:

    void Initialize(void){

       P1REN |= 0x02;                          
       P1OUT |= 0x02;                         
       P2REN |= 0x02;                          
       P2OUT |= 0x02;                          
       P1IE |= 0x02;                           
       P2IE |= 0x02;                              
       P1IFG &= ~0x02;                         
       P2IFG &= ~0x02;                         

       TA1CTL = TASSEL_1+ID_0+MC_2+TACLR;      
       TA1R = 40000;                         

       _BIS_SR(GIE);                           

    }

How do I prevent that the line P1IFG &= ~0x02; provokes an Interrupt? I'm new to microcontroller programming and read that this line provokes an interrupt if something changes in the P1IE register.

Thanks for your help!

The User's Guide says:

Writing to P1OUT, P1DIR, P2OUT, or P2DIR can result in setting the corresponding P1IFG or P2IFG flags.

However, this code clears the PxIFG flags before enabling the interrupts globally (GIE), so an unintentional interrupt cannot happen.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM