Jump to content
Sign in to follow this  
bperboy

Global Variable & InterruptORIG: Linker Error with Interrupt

Recommended Posts

I am working on a short program that controls some analog muxes. Before I add on the code for the interrupt routine to control the external pushbutton, it compiles and runs fine. After I add in the short amount of interrupt code, it gives me the following error:

 

 

"../lnk_msp430g2553.cmd", line 74: error: placement fails for object ".int02",

size 0x4 (page 0). Available ranges:

INT02 size: 0x2 unused: 0x2 max hole: 0x2

error: errors encountered during linking; "InputOutputSwitchbox.out" not built

 

>> Compilation failure

gmake: *** [inputOutputSwitchbox.out] Error 1

gmake: Target `all' not remade because of errors.

Build complete for project InputOutputSwitchbox

 

 

THe project is GRACE-enabled. Does that have anything to do with it?

 

/*
* ======== Standard MSP430 includes ========
*/
#include 

/*
* ======== Grace related includes ========
*/
#include 

/*
*  ======== main ========
*/

#define InputPort P2OUT
#define OutputPort P1OUT

int main(int argc, char *argv[])
{
   CSL_init();                     // Activate Grace-generated configuration
   WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
   __enable_interrupt();           // Set global interrupt enable


   int inputSelection=0;
   int outputSelection=0;

   // Initial Values
   inputSelection=0;
outputSelection=0;
InputPort = 0x00;
OutputPort = 0x00;

while(1){

   if(inputSelection == 3) InputPort |= 0x0F;
   else if(inputSelection == 2) InputPort |= 0x1A;
   else if(inputSelection == 1) InputPort |= 0x25;
   else InputPort |= 0x30;

   if(outputSelection == 3) OutputPort |= 0xF0;
   else if(outputSelection == 2) OutputPort |= 0xA1;
   else if(outputSelection == 1) OutputPort |= 0x58;
   else OutputPort |= 0x09;

}
   return (0);
}

// Update input/outputSelection variables after button press
#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR(void)
{
if( (P1IFG & BIT0) ) InputPort ^= BIT3;
P1IFG &= ~BIT0; // P1.0 IFG cleared
}

Share this post


Link to post
Share on other sites

Since the project is a GRACE project, it turns out that if I remove this line:

 

#pragma vector=PORT1_VECTOR

 

the program compiles correctly.

 

My next question is this: I've got a global variable that I'm trying to use as a counter that should get incremented by 1 every time the interrupt routine runs. Thing is, it resets itself to 0 after it exits the interrupt routine. Why is this, and how can I use the interrupt to make a counter that will be accessible in the Main() function?

Share this post


Link to post
Share on other sites

"../lnk_msp430g2553.cmd", line 74: error: placement fails for object ".int02",

size 0x4 (page 0). Available ranges:

INT02 size: 0x2 unused: 0x2 max hole: 0x2

 

That error means an interrupt vector is declared more than once.

 

There may be something in csl.h causing this problem.

 

Don't remove the #pragma vector=PORT1_VECTOR line, your code will not work without it. The interrupt code will not be called because the vector does not point to it.

Share this post


Link to post
Share on other sites
Yes, I think that may be the case.

 

The problem is that it must immediately precede the code you want called by that vector.

 

Well when I step through the program after a break-point and trigger the interrupt, it does go into my interrupt routine code. THe problem is that the global variable I have defined gets reset to 0 after the interrupt routine finishes.

Share this post


Link to post
Share on other sites

If there is a stub handler in the GRACE code, then your interrupt function probably should not have the __interrupt attribute.

 

I suspect your program is crashing due to stack corruption cause by improper function return. (reti vs. ret)

Share this post


Link to post
Share on other sites

I'm actually a summer intern at TI, and I just confirmed this with another employee familiar with GRACE. I will test it out when I get home from work today, and hopefully that will finish my project off.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...