From 0b0fcd5d2c041a65bc2dc18706e6a0127194cc08 Mon Sep 17 00:00:00 2001 From: anujpurwar007 <33223077+anujpurwar007@users.noreply.github.com> Date: Mon, 30 Oct 2017 23:18:51 +0530 Subject: [PATCH] interrupt To blink LED using interrupts in MSP430 MCU --- interrupt | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 interrupt diff --git a/interrupt b/interrupt new file mode 100644 index 0000000..a0c93bc --- /dev/null +++ b/interrupt @@ -0,0 +1,35 @@ +#include + +/* + * main.c + */ +int main(void) { + WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer + __enable_interrupt(); //enabling global interrupt + P1DIR|=0x41; + P1OUT|=0x01; + P1OUT&=~0x40; + //P1OUT&=~BIT0; + //P1OUT|=BIT6; + P1DIR&=~BIT3; + P1REN|=0x08; + P1OUT|=0x08; + //__delay_interrupt(); + //#pragma vector = Port1_vector; + //__interrupt void port_1(void) + P1IE|=0x08; + P1IES&=~BIT3; + + + + return 0; +} +//ISR +#pragma vector = PORT1_VECTOR //TO TELL THE ADDRESS OF THE PERIPHERAL FROM WHICH INTERRUPT HAS COME +__interrupt void port1(void) //JUMP TO THE ISR +{ + P1OUT^=0x41; + __delay_cycles(200000); + P1IFG&=0xF7; //DISABLES THE GIE PIN TO 0 TO AVOID MASKABLE INTERRUPTS + //WHEN THE INTERRUPT COMES THE FLAG IS SET TO 1 NOW TO CLEAR THE FLAG WE SET IT TO ZERO BY THE PREVIOUS COMMAND +}