Part Number: MSP430FR2000
Hello,
I'm working on a project requiring timer B and 2 port interrupts. In the project, I got an error as follows.
#10099-D</a> program will not fit into available memory, or the section contains a call site that requires a trampoline that can't be generated for this section. placement with alignment fails for section "ALL_FRAM" size 0x316. Available memory ranges: lnk_msp430fr2000.cmd /COMPILE line 132 C/C++ Problem
So, I tried as many methods as I could and the error was still there. So I have closely monitored the FRAM size and found that multiple lines that edit a global variable in an ISR caused the problem. The problematic code is as follows.
#include "msp430fr2000.h"
volatile int Cpwm = 0;
int main(void){ //P1.1 PULSES COMING FOR FAIL SAFE P1.3 RESET THE MICRO CONTROLLER
P1DIR |= 0x09; // P1.0 & P1.3 output
PM5CTL0 &= ~LOCKLPM5;
WDTCTL = WDTPW + WDTHOLD;
TB0CCTL0 = CCIE; // CCR0 interrupt enabled
TB0CCR0 = 40000; // 1
TB0CTL = TBSSEL_1 + MC_1 + ID_2; // SMCLK, contmode
P1DIR &= (~0x06); // Set P1.1 & P1.2 Set as Input
P1IES |= (~0x06); // rising Edge
P1IFG &= (~0x06); // Clear interrupt flag for P1.1 and P1.2
P1IE |= (0x06); // Enable interrupt for P1.3
_BIS_SR(GIE);
while(1){
P1OUT = 0x08;
}
}
// Timer A0 interrupt routine
#pragma vector=TIMER0_B0_VECTOR
__interrupt void Timer_B (void){
P1OUT &= ~(0x08); // RESET heartbeat P1.1
__delay_cycles(10000);
P1OUT |= 0x08;
__delay_cycles(100000);
if(((P1IN && 0x04)||(P1IN && 0x06) ) && (Cpwm == 0)){
P1OUT |= 0x01; //Failsafe on
}
}
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
if(P1IFG==0x02){
TB0R = 0;
P1IFG &= (~0x02); // HEART BEAT
if(Cpwm==0){
if((P1IN && 0x04)||(P1IN && 0x06) ){
P1OUT &= ~(0x08); // RESET heartbeat P1.1
__delay_cycles(10000);
P1OUT |= 0x08;
__delay_cycles(100000);
//oooooooooooooooooooooooooooooooooooooooo
if((P1IN && 0x04)||(P1IN && 0x06) ){
P1OUT |= 0x01; //Failsafe on
} //0000000000000000000000000000000000000000000000000000000000
}else{
P1OUT &= ~(0x01); // turn off fail safe
}
}
Cpwm = 0;
TB0R = 0;
}
else if(P1IFG==0x04){
Cpwm = Cpwm+1 ;
P1IFG &= (~0x04); // PWM
}
}

when I changed the code global variable to constant and commented the lines that edit the global variable in the ISR routine, then it was built with low memory. The code and the memory allocation are as follows.
#include "msp430fr2000.h"
const int Cpwm = 0;
int main(void){ //P1.1 PULSES COMING FOR FAIL SAFE P1.3 RESET THE MICRO CONTROLLER
P1DIR |= 0x09; // P1.0 & P1.3 output
PM5CTL0 &= ~LOCKLPM5;
WDTCTL = WDTPW + WDTHOLD;
TB0CCTL0 = CCIE; // CCR0 interrupt enabled
TB0CCR0 = 40000; // 1
TB0CTL = TBSSEL_1 + MC_1 + ID_2; // SMCLK, contmode
P1DIR &= (~0x06); // Set P1.1 & P1.2 Set as Input
P1IES |= (~0x06); // rising Edge
P1IFG &= (~0x06); // Clear interrupt flag for P1.1 and P1.2
P1IE |= (0x06); // Enable interrupt for P1.3
_BIS_SR(GIE);
while(1){
P1OUT = 0x08;
}
}
// Timer A0 interrupt routine
#pragma vector=TIMER0_B0_VECTOR
__interrupt void Timer_B (void){
P1OUT &= ~(0x08); // RESET heartbeat P1.1
__delay_cycles(10000);
P1OUT |= 0x08;
__delay_cycles(100000);
if(((P1IN && 0x04)||(P1IN && 0x06) ) && (Cpwm == 0)){
P1OUT |= 0x01; //Failsafe on
}
}
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
if(P1IFG==0x02){
TB0R = 0;
P1IFG &= (~0x02); // HEART BEAT
if(Cpwm==0){
if((P1IN && 0x04)||(P1IN && 0x06) ){
P1OUT &= ~(0x08); // RESET heartbeat P1.1
__delay_cycles(10000);
P1OUT |= 0x08;
__delay_cycles(100000);
//oooooooooooooooooooooooooooooooooooooooo
if((P1IN && 0x04)||(P1IN && 0x06) ){
P1OUT |= 0x01; //Failsafe on
} //0000000000000000000000000000000000000000000000000000000000
}else{
P1OUT &= ~(0x01); // turn off fail safe
}
}
// Cpwm = 0;
TB0R = 0;
}
else if(P1IFG==0x04){
// Cpwm = Cpwm+1 ;
P1IFG &= (~0x04); // PWM
}
}

So, why can't we edit any global variable, and is there any way to share data with different Interrupt service Routines and main code? Any kind of help is much appreciated.
