This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Why can't I declare an array of size 1024 int (Fault ISR.)? (Tiva C launchpad TM4C123G)

Using Tiva C launchpad TM4C123GXL
I am actually trying to make a device to FFT tri-axial acceleration readings.

I need 1024 samples to FFT them. once I try declaring the first array .. the debugger takes me to fault ISR.

Here is my simple main.

main(void)
{
int ArrX[1024]={0}; // the system lags here, and when I try debugging this line takes me to fault ISR.
int ArrY[1024]={0};
int ArrZ[1024]={0};
uint8_t i2c_data;
uint8_t dev_id[2];
int j =0,i=0;
signed int accelerationX, accelerationY, accelerationZ;

//
// Enable lazy stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
ROM_FPULazyStackingEnable();

//
// Set the clocking to run directly from the crystal.
//
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN);

//
// Enable the GPIO port that is used for the on-board LED.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

//
// Enable the GPIO pins for the LED (PF2 & PF3).
//
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);


//
// Initialize the UART.
//
ConfigureUART();

//
// Hello!
//
UARTprintf("Hello!\n");

/*I2C initialization with accelerometer interface*/
init_ADXL345_Accelerometer();

UARTprintf("Init done\n");

i2c_data = getAccelerometer_ID();
dev_id[0] = ((i2c_data & 0xF0) >> 4) + 0x30 + 0x07;
dev_id[1] = (i2c_data & 0x0F) + 0x30;

SetPowerMode(0x01);



while(1)
{

accelerationX = getAcceleration_X();

accelerationY = getAcceleration_Y();

accelerationZ = getAcceleration_Z();

if (accelerationX||accelerationY||accelerationZ)
{
ArrX[i]=accelerationX;
ArrY[i]=accelerationY;
ArrZ[i++]=(accelerationZ+200);
}
if (i==1024)
{
for(i=0;i<1024;i++)
UARTprintf("Acceleration X[%d]= %d\nAcceleration Y[%d]= %d\nAcceleration Z[%d]= %d\n",i,ArrX[i],i,ArrX[i],i,ArrX[i]);
i=0;
}
//
// Turn on the BLUE LED.
//
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
/*
Here I will put my FFT function.
*/
}
}

Regards.

  • Michel Mina said:
    int ArrX[1024]={0}; // the system lags here, and when I try debugging this line takes me to fault ISR.
    int ArrY[1024]={0};
    int ArrZ[1024]={0};
    uint8_t i2c_data;
    uint8_t dev_id[2];
    int j =0,i=0;
    signed int accelerationX, accelerationY, accelerationZ;

    From a quick calculation those local variables will require at least 12,312 bytes of stack space.

    When a new CCS project is created for a Tiva device the default stack size is 512 bytes. If there is insufficient stack space then the program may enter the fault ISR when it attempts to write off the end of the stack. Suggest either:

    a) Make the "large" arrays ArrX[], ArrY[] and ArrZ[] as global variables, so they don't use stack space.

    b) Under the CCS project properties -> CCS Build -> ARM Linker -> Basic Options increase the "Set C system stack size" value.