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.

CCS/EK-TM4C123GXL: Code not progressing, LED cannot light up

Part Number: EK-TM4C123GXL

Tool/software: Code Composer Studio

Hello, I am trying to make an LED turn on, to visually show that my code has completed; in other words, the LED lights up when the code is completed. However, it seems if I leave the line that has "createAnalyzingWave(analyzingFreq, analyzingWave);" (line 118)  uncommented, then the LED never lights up. I think this is a memory issue, because when I try to lower the macro ARRAYSIZE to a lower number (around 128), then the LED lights up. However, this has never happened to me before. In another project, with almost exactly the same code as this code, the LED would still light up, no matter the ARRAYSIZE.

I tried doing a system reset, but that didn't help. I increased the heap size to 16384, but that didn't do anything either. I'm just confused as to why the "createAnalyzingWave" function is giving me so much trouble, since it has worked perfectly fine in other programs that I've made.

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include "driverlib/adc.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gpio.h"

#define ARRAYSIZE 4096
#define PULSESNUMBER 16
#define DATAFREQ 1300
#define TWICETIMEINCREMENT (2 * (PULSESNUMBER * (1 / DATAFREQ)) / ARRAYSIZE)


// Creates data square wave (for testing purposes, for the real implementation actual ADC data will be used). This
// square wave has unity magnitude.
// The number of high values in each period is determined by high values = array size / (2 * number of pulses)
void createDataWave(uint8_t wave[]){
    uint8_t highValues = ARRAYSIZE / (PULSESNUMBER << 1);//(2 * PULSESNUMBER);
    uint8_t counter = 0;
    uint16_t p;
    for(p = 0; p < ARRAYSIZE; p++){
        if ((counter % 2) == 0){
            wave[p] = 1;
        } else{
            wave[p] = 0;
        }
        if ((p + 1) % highValues == 0){
            counter++;
        }
    }
}

// Creates analyzing square wave. This square wave has unity (1) magnitude.
// The number of high values in each period is determined by high values = (analyzingT/2) / time increment
void createAnalyzingWave(uint16_t analyzingFreq, uint8_t wave[]){
    //uint8_t highValues = (1 / analyzingFreq) / (((PULSESNUMBER * (1 / DATAFREQ)) / ARRAYSIZE) << 1); //(2 * (PULSESNUMBER * (1 / DATAFREQ)) / ARRAYSIZE);
    uint8_t highValues = (1 / analyzingFreq) / TWICETIMEINCREMENT;
    uint8_t counter = 0;
    uint16_t p;

    for(p = 1; p <= ARRAYSIZE; p++){
        if ((counter % 2) == 0){
            wave[p - 1] = 1;
        } else{
            wave[p - 1] = 0;
        }
        if (p % highValues == 0){
            counter++;
        }
    }
}



// Cross-Correlation algorithm. Cross-correlates 2 vectors of equal size with each other.
// Returns maximum cross-correlation value as a double.
// Inputs:
// 2 vectors, must be equal size
// Size of each vector
// Note: V3 is up to 4 times faster than V2
uint16_t crossCorrelationV3(uint8_t dataWave[], uint8_t analyzingWave[]){
    uint16_t i, j, k;
    uint16_t dec = ARRAYSIZE - 1;
    uint16_t maxCorr = 0;

    for (i = 1; i <= ARRAYSIZE; i++){
        uint16_t sum = 0;

        for (j = 0; j < i; j++){
            sum = dataWave[j] * analyzingWave[j + dec] + sum;
        }

        if (sum - maxCorr > 0){
            maxCorr = sum;
        }
        dec--;

    }

    uint16_t inc = 0;
    for (i = ARRAYSIZE; i >= 2; i--){
        uint16_t sum = 0;

        for (k = i; k >= 2; k--){
            sum = dataWave[k + inc - 1] * analyzingWave[k - 2] + sum;
        }

        if (sum - maxCorr > 0){
            maxCorr = sum;
        }
        inc++;

    }
    return maxCorr;
}

int main(void){
    // Enables the clock
    SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
    // Enables pin F
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    // Enables the output LEDs
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);

    uint16_t analyzingFreq = 1300;
    uint8_t samplesNumber = 6;

    uint8_t analyzingWave[ARRAYSIZE];
    uint8_t dataWave[ARRAYSIZE];


    createAnalyzingWave(analyzingFreq, analyzingWave);
/*

    uint8_t i;
    uint16_t sum = 0;

    for(i = 0; i < samplesNumber; i++){
        createDataWave(dataWave);
        sum = crossCorrelationV3(dataWave, analyzingWave) + sum;
    }
    uint16_t averageValue = sum / samplesNumber;*/
    while (1){
        if(1){   //if(averageValue == ARRAYSIZE >> 1){
            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 8);
        } else {
            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00);
        }
        SysCtlDelay(2000000);
    }
}

How do I turn the LED back on? Attached is the code. Thank you for your time.