Sign in

username:

password:



Not a member?

Search c54x



Search tips

Subscribe to c54x



c54x by Keywords

5409 | 5416 | AD5 | ADC | BIOS | Boot | Booting | Bootloader | C540 | C5402 | C5409 | C5416 | CCS | Codec | DMA | Dmad | DSK | DSKPlus | Dsplib | EVM | FFT | FIR | Flash | GPIO | HPI | Initialization | Interrupt | JTAG | LOG_printf | MCBSP | RFFT | RTDX | Sampling | STLM | UART | VC540


Discussion Groups

Discussion Groups | TMS320C54x | real-time application with TMS320C5402

Technical discussions about the TI C54x DSPs (including the c5401, c5402, c5402a, c5404, c5407, c5409, c5409a, c5410, c5410a, c5416, c5420, c5421, c5441, c549, c5470 and c5471).

  

Post a new Thread

real-time application with TMS320C5402 - seth_singh - May 8 3:06:00 2004



Hi there,
Is there any body who has any program, that can input some noise into
the board (TMS320C5402)any noise (etc. white noice) and output the
same noise (real time). Say to input the noise using a mic, and
output the noise using a speaker. There is a file called audio.pjt in
the TI folder, but i'm not very sure what kind of noise should be
used as an input. The program is attacted below.Plz if possible let
me kn how do i go about doing this task.

Thankz

/*
* Copyright 2001 by Texas Instruments Incorporated.
* All rights reserved. Property of Texas Instruments Incorporated.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
* U.S. Patent Nos. 5,283,900 5,392,448
*/
/* "@(#) DSP/BIOS 4.51.0 05-23-01 (barracuda-i10)" */
/*
* ======== audio.c ========
*/

#include <std.h>

#include <pip.h>
#include <log.h>
#include <trc.h>
#include <hst.h>

#include <string.h> /* memset() */
#include <stdarg.h> /* var arg stuff */

#include "dss.h"
#include "audio.h"

Int PHASE = 0; /* number of samples of phase difference
*/

static Uns allocBuf(PIP_Obj *out, Uns **buf);
static Void freeBuf(PIP_Obj *out);
static Uns getBuf(PIP_Obj *in, Uns **buf);
static Void process(Uns *src, Int size, Uns *dst);
static Void putBuf(PIP_Obj *out, Uns size);
static Void writeBuf(PIP_Obj *out, Uns *buf, Uns size);

static Int loadVal = 0;
static PIP_Obj *hostPipe = NULL;

/*
* ======== main ========
*/
Void main()
{
Int size;
Uns *buf;

#if AUDIO_USEHST
hostPipe = HST_getpipe(&hostOutputProbe);
#endif

DSS_init(); /* Initialize codec and serial port */

LOG_printf(&trace, "Audio example started!!\n");

/* Prime output buffers with silence */
size = allocBuf(&DSS_txPipe, &buf);
memset(buf, 0, size * sizeof (Uns));
putBuf(&DSS_txPipe, size);

size = allocBuf(&DSS_txPipe, &buf);
memset(buf, 0, size * sizeof (Uns));
putBuf(&DSS_txPipe, size - PHASE);

/* Fall into BIOS idle loop */
return;
}

/*
* ======== audio ========
*/
Void audio(PIP_Obj *in, PIP_Obj *out)
{
Uns *src, *dst;
Uns size;

if (PIP_getReaderNumFrames(in) == 0 || PIP_getWriterNumFrames
(out) == 0) {
error("Error: audio signal falsely triggered!");
}

/* get input data and allocate output buffer */
size = getBuf(in, &src);
allocBuf(out, &dst);

/* process input data in src to output buffer dst */
process(src, size, dst);

/* check for real-time error */
if (DSS_error != 0) {
LOG_printf(&trace,
"Error: DSS missed real-time! (DSS_error = 0x%x)",
DSS_error);
loadVal -= 1;
DSS_error = 0;
}

/* output data and free input buffer */
putBuf(out, size);
freeBuf(in);
}

/*
* ======== error ========
*/
Void error(String msg, ...)
{
va_list va;
va_start(va, msg);

LOG_error(msg, va_arg(va, Arg)); /* write error message to sys
log */
LOG_disable(LOG_D_system); /* stop system log */

for (;;) {
; /* loop for ever */
}
}

/*
* ======== load ========
*/
Void load(Int prd_ms)
{
static int oldLoad = 0;

/* display confirmation of load changes */
if (oldLoad != loadVal ) {
oldLoad = loadVal;
LOG_printf(&trace,
"load: new load = %d000 instructions every %d ms",
loadVal, prd_ms);
}

if (loadVal) {
AUDIO_load(loadVal);
}
}

/*
* ======== step ========
*/
Void step(void)
{
static Int direction = 1;

if (loadVal > MAXLOAD) {
direction = -1;
}
if (loadVal <= 0) {
direction = 1;
}

loadVal = loadVal + (100 * direction);
}

/*
* ======== allocBuf ========
*/
static Uns allocBuf(PIP_Obj *out, Uns **buf)
{
PIP_alloc(out);
*buf = PIP_getWriterAddr(out);;
return (PIP_getWriterSize(out));
}

/*
* ======== freeBuf ========
*/
static Void freeBuf(PIP_Obj *out)
{
PIP_free(out);
}

/*
* ======== getBuf ========
*/
static Uns getBuf(PIP_Obj *in, Uns **buf)
{
PIP_get(in);
*buf = PIP_getReaderAddr(in);;
return (PIP_getReaderSize(in));
}

/*
* ======== process ========
*/
static Void process(Uns *src, Int size, Uns *dst)
{
Int i;

for (i = size - 1; i >= 0; i--) {
dst[i] = src[i];
}

/* if hostPipe is non-NULL write data to this pipe */
if (hostPipe != NULL) {
writeBuf(hostPipe, dst, size);
}
}

/*
* ======== putBuf ========
*/
static Void putBuf(PIP_Obj *out, Uns size)
{
PIP_setWriterSize(out, size);
PIP_put(out);
}

/*
* ======== writeBuf ========
*/
static Void writeBuf(PIP_Obj *out, Uns *buf, Uns size)
{
Uns dstSize;
Uns *dst;
Int i;

/* allocate outBuffer for output */
dstSize = allocBuf(out, &dst);

/* copy data to output buffer (but not more than output buffer
size) */
for (i = (dstSize >= size) ? size : dstSize; i > 0; i--) {
*dst++ = *buf++;
}

/* put buffer to output pipe */
putBuf(out, size);
}




(You need to be a member of c54x -- send a blank email to c54x-subscribe@yahoogroups.com )