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/TMS320F28379D: Executing my CCS code using timers

Part Number: TMS320F28379D


Tool/software: Code Composer Studio

Hello all. This is Sainath. I am working with CCS v7. My code is going well in CCS but I need some help in how to execute my code for every 22.67uS using timers. Can any one help me out in doing so.

Please find my code attached below:


#include "F28x_Project.h" // Device Headerfile and Examples Include File

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

#define MAX 400

float buffer[400] = {0};

float result[500] = {0};

float input[500] = {0};

int p=0;

float filter[400] = {0.0163,-0.0069,0.0103,0.0088,0.0109,0.0165 ,0.0224,-0.0091,0.0094,-0.0081,0.0114,0.0060,0.0154,-0.0018,0.0339,0.1016,0.2103,0.2792,0.3139,0.2842,0.2850,0.2735,0.2478,0.2496,0.3135,0.3284,0.2305,0.1926,0.2342,0.3531,0.3701,0.3910,0.5126,0.6676,0.7166,0.7414,0.7653,0.7996,0.7991,0.8057,0.8329,0.8295,0.8479,0.8338,0.8140,0.8210,0.8301,0.8034,0.7677,0.7048,0.6983,0.6957,0.6248,0.5485,0.5858,0.6613,0.6770,0.5989,0.4721,0.3811,0.3567,0.3584,0.3613,0.3429,0.2659,0.2617,0.3239,0.3308,0.2589,0.1722,0.0947,0.0532,0.0821,0.0996,0.0790,0.0924,0.0873,0.0809,0.0878,0.0670,0.0727,0.0754,0.0137,0.0640,0.1973,0.3587,0.5031,0.6667,0.8310,0.7853,0.6194,0.4845,0.3999,0.2866,0.2158,0.2012,0.1592,0.0672,0.0787,0.1873,0.3205,0.3636,0.3666,0.4194,0.4000,0.3457,0.3121,0.3875,0.5380,0.6427,0.7295,0.7635,0.7545,0.7926,0.7347,0.6392,0.5417,0.4738,0.4846,0.5247,0.5699,0.5867,0.5555,0.4857,0.4225,0.4341,0.4204,0.2339,0.0294, -0.0797,-0.0217,0.0377,0.0392,0.0595,0.0751,0.1192,0.1348,0.1468,0.1402,0.0759,0.0367,0.0429,0.0627,0.0968,0.0975,0.0655,-0.0545,-0.2212,-0.2579,-0.2611,-0.3271,-0.4310,-0.4971,-0.5212,-0.5847,-0.6036,-0.5984,-0.5684,-0.4879,-0.5073,-0.5847,-0.5482,-0.4201,-0.3531,-0.3856,-0.4550,-0.5055,-0.5451,-0.5791,-0.5962,-0.6388,-0.7350,-0.7776,-0.7120,-0.6828,-0.6749,-0.7125,-0.7711,-0.7303,-0.6565,-0.5803,-0.5426,-0.5471,-0.5299,-0.4884,-0.4623,-0.4409,-0.4146,-0.3436,-0.2169,-0.1125,-0.0901,-0.1890,-0.3435,-0.5004,-0.6040,-0.5998,-0.5177,-0.3957,-0.2677,-0.1347,-0.0363,0.0253,0.0351,0.0029,-0.0009,-0.0112,-0.0297,-0.0432,-0.0944,-0.1792,-0.2360,-0.2734,-0.2474,-0.1670,-0.1473,-0.2091,-0.3363,-0.4371,-0.4424,-0.3652,-0.2777,-0.2153,-0.2218,-0.3008,-0.2942,-0.2166,-0.2272,-0.3096,-0.3245,-0.2888,-0.3171,-0.4544,-0.5883,-0.5809,-0.4863,-0.4118,-0.4249,-0.4342,-0.3705,-0.3185,-0.3143,-0.3424,-0.3746,-0.3404,-0.2070,-0.1125,-0.1510,-0.3132,-0.4736,-0.4586,-0.3453,-0.3190,-0.3912,-0.4579,-0.4528,-0.3677,-0.3440,-0.4265,-0.5006,-0.5111,-0.4322,-0.3290,-0.2860,-0.3341,-0.4168,-0.4527,-0.4149,-0.3436,-0.3391,-0.4395,-0.5568,-0.5878,-0.5730,-0.5641,-0.5750,-0.5971,-0.6265,-0.6824,-0.7018,-0.6522,-0.6117,-0.6177,-0.5788,-0.5188,-0.4928,-0.4069,-0.2427,-0.1039,-0.0690,-0.1012,-0.1470,-0.1452,-0.0515,0.0414,0.0296,-0.0438,-0.1505,-0.2681,-0.2580,-0.1727,-0.1557,-0.1847,-0.2377,-0.2570,-0.1141,0.0841,0.1054,-0.0175,-0.1747,-0.2758,-0.2191,-0.0910,-0.0671,-0.1691,-0.3220,-0.4546,-0.5044,-0.4895,-0.4320,-0.3358,-0.2927,-0.3598,-0.3938,-0.2742,-0.0990,0.0405,0.1248,0.1158,0.0291,-0.0394,-0.0489,-0.0165,0.0964,0.2615,0.2798,0.0444,-0.2340,-0.3210,-0.2323,-0.0917,-0.0210,-0.1063,-0.2705,-0.3724,-0.4099,-0.4142,-0.3882,-0.3484,-0.2798,-0.2075,-0.1987,-0.2353,-0.2875,-0.3217,-0.1885,0.0804,0.2025,0.1574,0.1402,0.1379,0.1548,0.3040,0.4565,0.4843,0.4967,0.4863,0.3980,0.3622,0.3875,0.3585,0.3168,0.2960,0.2637,0.2711,0.3394,0.4037,0.4219,0.4118,0.4016,0.3438,0.1996,0.0535,-0.0305,-0.0494,-0.0120,-0.0168,-0.1003,-0.1482,-0.1557,-0.1784,-0.1451,-0.0636,-0.0514,-0.1244,-0.2374,-0.3208,-0.3103,-0.2920,-0.3172};

int pointer = 0;

void getAudioSamplesFromFile(FILE *sampleFile, float samples[]) // Function to pretend like storing values in a buffer


{
float sample;

int i=0;

for (i=0; i <= 500; i++)

{
fscanf(sampleFile, "%e", &sample);

samples[i] = sample;

}
return;

}


float READ_FLOAT_EXT_EEPROM(float input[], int *counter) // Function to pretend like ADC is reading values from the buffer

{

float next = input[*counter];

(*counter)++;

return next;


}

float Corr()

{

float out = 0;

int i=0;

for (i = 0; i < MAX; i++)

{
int index = ((i + pointer + 1) % MAX);

out = out + (buffer[index-1] * filter[i]);


}


result[p] = out;

p++;

return out;

}


int main(void)

+{

clock_t t;

t = clock();

FILE *inputFile;

inputFile = fopen("C:/Users/ss474/workspace_v7/sample_7060.csv","r");

getAudioSamplesFromFile(inputFile, input);

fclose(inputFile);

int counter = 0;

float sample;

int j=0;

for(j=0;j<500;j++)

{

sample = READ_FLOAT_EXT_EEPROM(input,&counter); // Reading values from the ADC


buffer[pointer] = sample;


Corr(); // Correlation with the shotgun pattern


pointer++;

if(pointer == MAX)


{
pointer = 0;

}

}

float d;

d = clock() - t;

}

 

I want to execute my code for every 22.67uS i.e.., 44.1kHz using timers inside an Interrupt Service Routine.

Thank you.

Best Regards,

Sainath.