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

CCS/MSP430G2553: MSP430 CCS #pragma method of interrupts

$
0
0

Part Number:MSP430G2553

Tool/software: Code Composer Studio

I'm using the MSP430G2553 launchpad with CCS. I use S2 on Port1 pin3 to cause an interrupt to the MCU.

I write my code below. 

#include "msp430g2231.h"  //Contains all definitions for registers and built-in functions 
int main(void)  //Main program
{
   WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
  
   P1DIR |= BIT0; // Set P1.0 to output and P1.3 to input direction
   P1OUT &= ~BIT0; // set LED Off
   P1IE |= BIT3; // P1.3 interrupt enabled
   P1IES = BIT3; //Interrupt is HIGH to LOW
   P1IFG &= ~BIT3; // P1.3 interrupt flag cleared  
   __bis_SR_register(GIE); // Enable all interrupts (Clear GIE in SR)
  
   while(1) //Loop forever, we'll do our job in the interrupt routine...
   {}
}

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
    P1OUT ^= BIT0;  // Toggle P1.0
    P1IFG &= ~BIT3; // P1.3 interrupt flag cleared
}		

The intention of this question is to properly understand  #pragma vector=PORT1_VECTOR line

I now paste an excerpt from the datasheet below,

As per this, the place that must have the address of the ISR should be 0FFE4h. But I would not find the place within the CCS environment which does this operation.

However, I noticed if I write just 2 instead of PORT1_VECTOR, my code happens to work.  Below is an excerpt from the Msp430g2553 header where I view the content of PORT1_VECTOR. I find the way its defined a bit weird, in the sense that very difficult to understand. I would appreciate the uses of the following #defines could be more elaborately explained.

 My program worked when I simply had #define PORT1_VECTOR 2.

First,  I would like to know why #define PORT1_VECTOR 2 not written here. I can observe a ".int02". May be this is an integer 2? If so, why would the header file specifically mention the #define in this manner without simply stating #define PORT1_VECTOR 2 ? I would like to know that reason.  Would  truly appreciate your kind explanation there.

Secondly, where is the list of vector numbers relating to all interrupt sources? In this case, for PORT 1 interrupts it is 2, but surely in somewhere in this code, the actual memory address of the ISR must be written to the memory location 0FFE4h. Otherwise when an interrupt is triggered, the MCU would not know to direct to the ISR. I would like to see the code for this here. I could not find this implementation within the header file. 

Thank you sincerely for all your answers and time. 


Viewing all articles
Browse latest Browse all 22138