You are on page 1of 3

HalfaGeek

POSTED BY

GANESHREDCOBRA
POSTED ON

NOVEMBER 8, 2012
POSTED UNDER

EMBEDDED SYSTEMS, MSP430 LAUNCHPAD, UBUNTU


COMMENTS

1 COMMENT

MSP430 Polling Vs Interrupt

In this example other than the usual polling method we uses an interrupt to get the switch reading
In MSP430 port1 interrupt service routine is wrien like this

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{

I used code composer studio to get the output of interrupt codeThe mspgcc interrupt service routine is like this but i
failed to get the output using mspgcc

//port1 interrupt service routine


void Port_1 (void) __attribute__((interrupt(PORT1_VECTOR)));
void Port_1 (void)
{

This example also reads switch and toggles lightThis is the full code of the interrupt program..
/*interrupt.c
ganeshredcobra@gmail.com
GPL
*/
#include <msp430g2553.h>
#define LED1 BIT0
#define LED2 BIT6
#define BUTTON BIT3
volatile unsigned int i;//to prevent optimization
void main(void)
{
WDTCTL=WDTPW+WDTHOLD;
P1DIR |= (LED1+LED2);//
P1OUT &= ~(LED1+LED2);
P1IE |= BUTTON;
P1IFG &= ~BUTTON;

//__enable_interrupt();//enable all interrupts


_BIS_SR(LPM4_bits+GIE);
for(;;)
{}
}

//port1 interrupt service routine


#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
P1OUT ^= (LED1+LED2);
P1IFG &= ~BUTTON;
P1IES ^= BUTTON;
}

CCS (hps://importgeek.wordpress.com/tag/ccs/)
code composer studio (hps://importgeek.wordpress.com/tag/code-composer-studio/)
Embedded Linux (hps://importgeek.wordpress.com/tag/embedded-linux/)
Embedded systems (hps://importgeek.wordpress.com/tag/embedded-systems/)
GPIO Programming (hps://importgeek.wordpress.com/tag/gpio-programming/)
MSP430 Launchpad (hps://importgeek.wordpress.com/tag/msp430-launchpad/)
polling (hps://importgeek.wordpress.com/tag/polling/)

One thought on MSP430 Polling Vs Interrupt


1.
Ashok Kumar A M says:
December 16, 2012 at 4:35 pm
Reblogged this on Ashok Kumar Blog.

Reply

Create a free website or blog at WordPress.com.

You might also like