Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

CCS/OMAPL138B-EP: Help with sine wave generation.

$
0
0

Part Number:OMAPL138B-EP

Tool/software: Code Composer Studio

Hi,

I am using OMAPL138B  LCDK version for generation of sine wave using Code Composer Studio 5.5.0. I am facing problem in generation of sine wave. I have tried generation using look up table and using 'sin' function by using the following codes.

USING LOOK UP TABLE CODE:

#include "L138_LCDK_aic3106_init.h"
#define LOOPLENGTH 100
#define BUFLENGTH 256
int16_t sine_table[LOOPLENGTH] =
{0,63,125,187,249,309,368,426,482,536,588,637,685,729,771,809,844,876,905,930,951,969,982,992,998,1000,998,992,982,969,951,930,905,876,844,809,771,729,685,637,588,536,482,426,368,309,249,187,125,63,0,-63,-125,-187,-249,-309,-368,-426,-482,-536,-588,-637,-685,-729,-771,-809,-844,-876,-905,-930,-951,-969,-982,-992,-998,-1000,-998,-992,-982,-969,-951,-930,-905,-876,-844,-809,-771,-729,-685,-637,-588,-536,-482,-426,-368,-309,-249,-187,-125,-63};
int16_t sine_ptr = 0; // pointer into lookup table
int32_t buffer[BUFLENGTH];
int16_t buf_ptr = 0;
interrupt void interrupt4(void) // interrupt service routine
{
int16_t sample;
sample = sine_table[sine_ptr]; // read sample from table
output_left_sample(sample); // output sample
sine_ptr = (sine_ptr+1) %LOOPLENGTH; // increment table index
buffer[buf_ptr] = (int32_t)(sample); // store sample in buffer
buf_ptr = (buf_ptr+1) %BUFLENGTH; // increment buffer index
return;
}
int main(void)
{
L138_initialise_intr(FS_48000_HZ,ADC_GAIN_0DB,DAC_ATTEN_0DB,LCDK_LINE_INPUT);
while(1);
}

USING SINE FUNCTION:

#define PI 3.14159265358979
float frequency = 1000.0;
float amplitude = 20000.0;
float theta_increment;
float theta = 0.0;
interrupt void interrupt4(void) // interrupt service routine
{
 theta_increment = 2*PI*frequency/SAMPLING_FREQ;
 theta += theta_increment;
 if (theta > 2*PI) theta -= 2*PI;
 output_left_sample((int16_t)(amplitude*sin(theta)));
 return;
}
int main(void)
{
 L138_initialise_intr(FS_8000_HZ,ADC_GAIN_0DB,DAC_ATTEN_0DB,LCDK_LINE_INPUT);
 while(1);
}

OUTPUT:


Output for both the code is coming the same. The output has been attached. Please help! Where am I going wrong? Because both the codes are running fine in MATLAB. Also I need help in the area of setting the parameters of graph tool.

Thank You in advance. 


Viewing all articles
Browse latest Browse all 17527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>