Forums

How to convert tha data to analog form

Started by Tang...@hotmail.com April 9, 2009
I am a newcomer of TMS320C31. I am facing a problem to convert the data stored from memory address 0x809d00 to 0x809d7f to analog form so that it can be came out through the output port to a speaker. What is the additional codes needed? Thank you very much. The codes i done so far are shown in below.

/*SHIFT.C - ILLUSTRATES 180 DEGREES DELAY IN PHASE */
#include "math.h"
#define pi 3.1415926
#define Fs 25000
#define inp 1000*sin(2*pi*T*1000/Fs)

main()
{
int T;
double xin, x, yo;

volatile int *IO_OUTPUT = (volatile int*) 0x809d00;
volatile int *IO_INPUT = (volatile int*) 0x809d80;
for (T = 0; T < 128; T++)
{
xin = inp/1000; /*input between 1 and -1 */
if (yo >= xin) /*is signal falling or rising*/
x = acos(xin); /*signal is falling */
else /*otherwise */
x = asin(xin) - (pi/2); /*signal is rising */
x = x - (pi); /*shift by 180 degrees */
*IO_OUTPUT++00*cos(x); /*shifted output value */
yo = xin; /*store xin value */
}

for (T = 0; T < 128; T++)
{
xin = inp/1000; /*input between 1 and -1 */
if (yo >= xin) /*is signal falling or rising*/
x = acos(xin); /*signal is falling */
else /*otherwise */
x = asin(xin) - (pi/2); /*signal is rising */
x = x ; /*shift by 0 degrees */
*IO_INPUT++00*cos(x); /*shifted output value */
yo = xin; /*store xin value */
}

}

_____________________________________