bperboy 0 Posted July 27, 2011 Share Posted July 27, 2011 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 } Quote Link to post Share on other sites
bluehash 1,581 Posted July 27, 2011 Share Posted July 27, 2011 umm.. looks like you are running out of space, which is surprising. Try optimizing your code: Project|Properties|C/C++Build|MSP430Compiler|BasicOptions Quote Link to post Share on other sites
bperboy 0 Posted July 27, 2011 Author Share Posted July 27, 2011 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? Quote Link to post Share on other sites
oPossum 1,083 Posted July 27, 2011 Share Posted July 27, 2011 "../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. bluehash 1 Quote Link to post Share on other sites
bluehash 1,581 Posted July 27, 2011 Share Posted July 27, 2011 Thanks opossum... bperboy.. did you update your grace installation? Quote Link to post Share on other sites
bperboy 0 Posted July 27, 2011 Author Share Posted July 27, 2011 What I am saying is that I think the GRACE confuguration puts that line in te code somewhere else. Quote Link to post Share on other sites
oPossum 1,083 Posted July 27, 2011 Share Posted July 27, 2011 Yes, I think that may be the case. The problem is that it must immediately precede the code you want called by that vector. Quote Link to post Share on other sites
bperboy 0 Posted July 27, 2011 Author Share Posted July 27, 2011 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. Quote Link to post Share on other sites
oPossum 1,083 Posted July 27, 2011 Share Posted July 27, 2011 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) Quote Link to post Share on other sites
bperboy 0 Posted July 27, 2011 Author Share Posted July 27, 2011 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. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.