Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 22012

CCS/MSP430G2452: interrupt issue

$
0
0

Part Number:MSP430G2452

Tool/software: Code Composer Studio

Hello, 

I am new to programming microcontrollers, my issue is with interrupts. I have created two interrupts on different ports within port 1, my code follows.

My issue is that I would like to not run an interrupt if another has been executed. I am doing this with variables by giving " int variable = (variable + 1); " in the first if statement. 

How can I have the correct syntax so that I can not enter my second interrupt if a variable has not been met?

thank you!

#include <msp430.h>#define MOTOR BIT0

#define LED_M BIT6
#define BOWL BIT3
#define CONTAINER BIT4
#define LED_C BIT7

int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= (MOTOR + LED_M + LED_C); // Set P1.0 to output direction
P1OUT &= ~(MOTOR + LED_M); // set P1.0 to 0 (LED OFF)
P1IE |= (BOWL + CONTAINER); // P1.3 & P1.4 interrupt enabled
P1IFG &= ~(CONTAINER + BOWL); //P1.4 & P1.3 IFG cleared

__enable_interrupt(); // enable all interrupts
const int variable =0;

for(;;)
{


}
}

// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1_ISR(void)
{
if(P1IFG & BIT4)
//CONTAINER
{

P1OUT ^=(LED_C);
int variable = (variable + 1);
P1IFG &= ~CONTAINER; // P1.3 IFG cleared
P1IES ^= CONTAINER; // toggle the interrupt edge, the interrupt vector will be called when P1.3 goes from HitoLow as well as LowtoHigh


}
if(P1IFG & BIT3 & variable==0)
//BOWL
{
P1OUT ^= (MOTOR + LED_M); // P1.0 & P1.6 toggle
P1IFG &= ~BOWL; // P1.3 IFG cleared
P1IES ^= BOWL; // toggle the interrupt edge, the interrupt vector will be called when P1.3 goes from HitoLow as well as LowtoHigh

}}


Viewing all articles
Browse latest Browse all 22012

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>