Charles
Charles

Reputation: 1

What is the reason that I have an error "expected an expression" in this code in CCS 5.5.0?

I recently started to learn C. I have to complete a Goertzel algorithm to detect the presence of the 8 frequencies in a data.bin file. I'm working on CCS 5.5.0. But in the following code I've got the error "#29 expected an expression" at the both lines where my for-loop begin. Of course the code is not finished yet and it's only a part of the code. But I think it's more a problem of syntax but I can't find it. Thank you !

/*
 *  ======== gtz.c ========
 */

#include <xdc/std.h>
#include <xdc/runtime/System.h>

#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Task.h>

#include <xdc/runtime/Types.h>
#include <xdc/runtime/Timestamp.h>

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "gtz.h"

void clk_SWI_Read_Data(UArg arg0);
void clk_SWI_GTZ_All_Freq(UArg arg0);

extern void task0_dtmfGen(void);
extern void task1_dtmfDetect(void);

extern int sample, tdiff, tdiff_final, gtz_out[8];
extern short coef[8];
extern int flag;

short data[NO_OF_SAMPLES];
short *buffer;
static int i;

/*
 *  ======== main ========
 */
int main() {
    System_printf("\n System Start\n");
    System_flush();

    /* Read binary data file */
    FILE* fp = fopen("../data.bin", "rb");
    if(fp==0) {
        System_printf("Error: Data file not found\n");
        System_flush();
        return 1;
    }
    fread(data, 2, NO_OF_SAMPLES, fp);
    buffer = (short*)malloc(2*8*10000);

    /* Create a Clock Instance */
    Clock_Params clkParams;

    /* Initialise Clock Instance with time period and timeout (system ticks) */
    Clock_Params_init(&clkParams);
    clkParams.period = 1;
    clkParams.startFlag = TRUE;

    /* Instantiate ISR for tone generation  */
    Clock_create(clk_SWI_Read_Data, TIMEOUT, &clkParams, NULL);

    /* Instantiate 8 parallel ISRs for each of the eight Goertzel coefficients */
    Clock_create(clk_SWI_GTZ_All_Freq, TIMEOUT, &clkParams, NULL);

    /* Start SYS_BIOS */
    BIOS_start();
}

/*
 *  ====== clk_SWI_Generate_DTMF =====
 *  Dual-Tone Generation
 *  ==================================
 */
void clk_SWI_Read_Data(UArg arg0) {
    static int tick;
    tick = Clock_getTicks();
    sample = data[tick%NO_OF_SAMPLES];
}

/*
 *  ====== clk_SWI_GTZ =====
 *  gtz sweep
 *  ========================
 */
void clk_SWI_GTZ_All_Freq(UArg arg0) {
    // define variables for timing
    static int start, stop;

    // define feedback times as N
    static int N = 0;

    //Record start time
    start = Timestamp_get32();

    short input = (short) (sample);

    //static int number_bits_used;
    //static float normalized_value_coef1;

    int Goertzel_values[8] = {0,0,0,0,0,0,0,0};
    short delay_values[8] = {0,0,0,0,0,0,0,0};
    short delay_1_values[8] = {0,0,0,0,0,0,0,0};
    short delay_2_values[8] = {0,0,0,0,0,0,0,0};
    short prod1_values[8] = {0,0,0,0,0,0,0,0};
    short prod2_values[8] = {0,0,0,0,0,0,0,0};
    short prod3_values[8] = {0,0,0,0,0,0,0,0};

    int R_in = sample;
    input = (short) R_in;
    input = input>>4;

    input = (short)sample;
    input = input>>4;

    /*
     * TODO 1. Complete the feedback loop of the GTZ algorithm */
    /* ========================= */

    for (int i=0; i<8; i++){ // **Where the error appears**
        prod1_values[i] = (delay_1_values[i] * coef[i]) >> 14;
        delay_values[i] = input + (short) prod1_values[i] - delay_2_values[i];
        delay_2_values[i] = delay_1_values[i];
        delay_1_values[i] = delay_values[i];
    }
    N++;
    /* ========================= */

    //Record stop time
    stop = Timestamp_get32();
    //Record elapsed time
    tdiff = stop-start;

    if (N == 206) {
        //Record start time
        start = Timestamp_get32();

        /* TODO 2. Complete the feedforward loop of the GTZ algorithm*/
        /* ========================= */
        for (int i=0; i<8; i++){ 
            prod1_values[i] = (delay_1_values[i] * delay_1_values[i]) >> 14;
            prod2_values[i] = (delay_2_values[i] * delay_2_values[i]) >> 14;
            prod3_values[i] = (delay_1_values[i] * coef[i]) >> 14;
            prod3_values[i] = prod3_values[i] * delay_2_values[i];

            Goertzel_values[i] =prod1_values[i]+prod2_values[i] - prod3_values[i];
            Goertzel_values[i] <<= 4;
            gtz_out[i] = Goertzel_values[i];
        }
        /* gtz_out[..] = ... */
        /* gtz_out[..] = ... */
        /* ========================= */
        flag = 1;
        N = 0;

        //Record stop time
        stop = Timestamp_get32();
        //Record elapsed time
        tdiff_final = stop-start;
    }
}

I tried to open the file on VSCODE to see if any solution was proposed but any problem was declared. I verified the syntax but I couldn't find the error.

Upvotes: 0

Views: 158

Answers (0)

Related Questions