0% found this document useful (0 votes)
39 views

Experiment No. 4: Sine Wave Generation: Theory

This document describes an experiment to generate a sine wave using an interrupt method. It explains that interrupts will be used to trigger an interrupt service routine that calculates new sine wave sample values using the sine function. The procedure connects an output to an oscilloscope. The program code initializes communication and interrupts, sets the sampling frequency and generated sine wave frequency, calculates the angle offset per sample, generates samples within the interrupt routine using sine of the changing angle, and outputs the samples.

Uploaded by

Shaheen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Experiment No. 4: Sine Wave Generation: Theory

This document describes an experiment to generate a sine wave using an interrupt method. It explains that interrupts will be used to trigger an interrupt service routine that calculates new sine wave sample values using the sine function. The procedure connects an output to an oscilloscope. The program code initializes communication and interrupts, sets the sampling frequency and generated sine wave frequency, calculates the angle offset per sample, generates samples within the interrupt routine using sine of the changing angle, and outputs the samples.

Uploaded by

Shaheen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment No.

4: Sine Wave Generation

Theory –
In two ways sinewave can be generated. One by using polling method and later by using
interrupt method. In polling method processor continuously monitors for next sample. In interrupt
method, when the interrupt is generated, interrupt service routine will be executed and all samples are
fetched from the sin() function.
Here we are using interrupt method for generating sine wave.

Procedure –
1. Take output from LINE_OUT and connect it to DSO to observe the output.

Program –
// Com m routines included in C6xdskinit.c

#include "dsk6713_aic23.h" // needed to access codec function


#include <math.h> // needed for sin(*/ function
#define PI 3.14159265359 // define the constant PI
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; // sampling frequency of codec
float f0=1000; // generated sinusoid frequency
float fs_float; // needed for calculating offset
float angle=0; // sin(*/ argument in radians
float offset; // sin(*/ argument change per sample period
short amp=20; // sine amplitude scaling factor
short sine_value; // value sent to codec
interrupt void c_int11() // interrupt service routine
{
switch(fs) // get sampling freq in Hz from fs
{
case DSK6713_AIC23_FREQ_8KHZ:
case DSK6713_AIC23_FREQ_16KHZ:
case DSK6713_AIC23_FREQ_24KHZ:
case DSK6713_AIC23_FREQ_32KHZ:
case DSK6713_AIC23_FREQ_48KHZ:
fs_float=8000*fs;
break;
case DSK6713_AIC23_FREQ_44KHZ:
fs_float=44000;
break;
case DSK6713_AIC23_FREQ_96KHZ:
fs_float=96000;
break;
}
offset=2*PI*f0/fs_float; // set offset value
angle = angle + offset; // previous angle plus offset

DIGITAL SIGNAL PROCESSING LAB MANUAL 1


if (angle > 2*PI) // reset angle if > 2*PI
angle -= 2*PI; // angle = angle - 2*PI
sine_value=(short)1000*amp*sin(angle); // calculate current output sample
output_left_sample(sine_value); // output each sine value
return; // return from interrupt
}
void main()
{
comm_intr(); // init DSK, codec, SP0 for interrupts
while(1); // wait for an interrupt to occur
}

DIGITAL SIGNAL PROCESSING LAB MANUAL 2

You might also like