DSPRelated.com
Forums

Broken TI EzDSP tutorial "volume"

Started by Chris Carlen July 1, 2004
Hi:

I have the following problem:

CCS for c2x 2.20.0, board rev 00.00.3184, target silicon 00.00.02

Using CCS (above version) and the Spectrum Digital EzDSP target board, 
and running through the tutorial, I have encountered the following 
problem with an example program:

Tutorial|CCS IDE|Developing a simple program|Changing Program Options 
and Fixing Syntax Errors

1. at the bottom of this section, when the program on the target is run, 
there appears to be a bug in the program which causes the �volume 
example started� text to print periodically, interspersed with the text 
�begin processing�.  Thus, is appears that the CPU is periodically 
resetting or that the program is starting over from the beginning, even 
though the code should implement an infinite loop in main() that only 
repeats the output of the text �begin processing� over and over.

2. If I break the running program and then put the cursor on the line: 
puts("volume example started\n"); and select Debug|RuntoCursor then the 
program will run to that point, which shouldn't happen since it should 
have never gotten out of the while(1) loop.

3. The program prints approximately 30 �begin processing� outputs per 
every �volume example started� output.

4. More evidence that the program is resetting is that in the section 
~|Developing a simple program|Adjusting the Gain, after the value of 
variable gain is set to 10, then when the animation is resumed, the 
graph only briefly shows the resulting increase in gain, before it 
returns to displaying the result of gain=1 after outputting the text: 
�volume example started�

There are quite a few project files, so it's hard to say where the 
problem arises.  There is nothing obvious to me in the C source, shown 
below:

Here are the main source files, volume.c and volume.h:

/*
  *  Copyright 2003 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.
  *
  */
/* "@(#) DSP/BIOS 4.90.280 12-12-03 (bios,dsk2812-a04)" */
/*
  *  ======== volume.h ========
  *
  */

#ifndef __VOLUME_H
#define __VOLUME_H

#ifndef TRUE
#define TRUE 1
#endif

#define BUFSIZE 0x64

#define FRAMESPERBUFFER 10

#define MINGAIN 1
#define MAXGAIN 10

#define MINCONTROL 0
#define MAXCONTROL 19

#define BASELOAD 1

struct PARMS {
	int Beta;
	int EchoPower;
	int ErrorPower;
	int Ratio;
	struct PARMS *Link;
};

#endif /* __VOLUME_H */




/*
  *  Copyright 2003 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.
  *
  */
/* "@(#) DSP/BIOS 4.90.280 12-12-03 (bios,dsk2812-a04)" */
/***************************************************************************/
/* 
    */
/*     V O L U M E . C 
    */
/* 
    */
/*     Audio gain processing in a main loop 
    */
/* 
    */
/***************************************************************************/

#include <stdio.h>

#include "volume.h"

/* Global declarations */
int inp_buffer[BUFSIZE];       /* processing data buffers */
int out_buffer[BUFSIZE];

int gain = MINGAIN;                      /* volume control variable */
unsigned int processingLoad = BASELOAD;  /* processing routine load value */

struct PARMS str =
{
     2934,
     9432,
     213,
     9432,
     &str
};

/* Functions */
extern void load(unsigned int loadValue);

static int processing(int *input, int *output);
static void dataIO(void);


/*
  * ======== main ========
  */
void main()
{
     int *input = &inp_buffer[0];
     int *output = &out_buffer[0];

     puts("volume example started\n");

     /* loop forever */
     while(TRUE)
     {
         /*
          *  Read input data using a probe-point connected to a host file.
          *  Write output data to a graph connected through a probe-point.
          */
         dataIO();

         #ifdef FILEIO
         puts("begin processing");        /* deliberate syntax error */
         #endif

         /* apply gain */
         processing(input, output);
     }
}

/*
  *  ======== processing ========
  *
  * FUNCTION: apply signal processing transform to input signal.
  *
  * PARAMETERS: address of input and output buffers.
  *
  * RETURN VALUE: TRUE.
  */
static int processing(int *input, int *output)
{
     int size = BUFSIZE;

     while(size--){
         *output++ = *input++ * gain;
     }

     /* additional processing load */
     load(processingLoad);

     return(TRUE);
}

/*
  *  ======== dataIO ========
  *
  * FUNCTION: read input signal and write processed output signal.
  *
  * PARAMETERS: none.
  *
  * RETURN VALUE: none.
  */
static void dataIO()
{
     /* do data I/O */

     return;
}



-- 
_____________________
Christopher R. Carlen
crobc@earthlink.net
Suse 8.1 Linux 2.4.19

The watchdog probably wasn't disabled.  Under the GEL menu their should be
an option to turn off the watch dog.

Brad

"Chris Carlen" <crobc@BOGUS_FIELD.earthlink.net> wrote in message
news:zyLEc.709$oD3.645@newsread1.news.pas.earthlink.net...
> Hi: > > I have the following problem: > > CCS for c2x 2.20.0, board rev 00.00.3184, target silicon 00.00.02 > > Using CCS (above version) and the Spectrum Digital EzDSP target board, > and running through the tutorial, I have encountered the following > problem with an example program: > > Tutorial|CCS IDE|Developing a simple program|Changing Program Options > and Fixing Syntax Errors > > 1. at the bottom of this section, when the program on the target is run, > there appears to be a bug in the program which causes the &#4294967295;volume > example started&#4294967295; text to print periodically, interspersed with the text > &#4294967295;begin processing&#4294967295;. Thus, is appears that the CPU is periodically > resetting or that the program is starting over from the beginning, even > though the code should implement an infinite loop in main() that only > repeats the output of the text &#4294967295;begin processing&#4294967295; over and over. > > 2. If I break the running program and then put the cursor on the line: > puts("volume example started\n"); and select Debug|RuntoCursor then the > program will run to that point, which shouldn't happen since it should > have never gotten out of the while(1) loop. > > 3. The program prints approximately 30 &#4294967295;begin processing&#4294967295; outputs per > every &#4294967295;volume example started&#4294967295; output. > > 4. More evidence that the program is resetting is that in the section > ~|Developing a simple program|Adjusting the Gain, after the value of > variable gain is set to 10, then when the animation is resumed, the > graph only briefly shows the resulting increase in gain, before it > returns to displaying the result of gain=1 after outputting the text: > &#4294967295;volume example started&#4294967295; > > There are quite a few project files, so it's hard to say where the > problem arises. There is nothing obvious to me in the C source, shown > below: > > Here are the main source files, volume.c and volume.h: > > /* > * Copyright 2003 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. > * > */ > /* "@(#) DSP/BIOS 4.90.280 12-12-03 (bios,dsk2812-a04)" */ > /* > * ======== volume.h ======== > * > */ > > #ifndef __VOLUME_H > #define __VOLUME_H > > #ifndef TRUE > #define TRUE 1 > #endif > > #define BUFSIZE 0x64 > > #define FRAMESPERBUFFER 10 > > #define MINGAIN 1 > #define MAXGAIN 10 > > #define MINCONTROL 0 > #define MAXCONTROL 19 > > #define BASELOAD 1 > > struct PARMS { > int Beta; > int EchoPower; > int ErrorPower; > int Ratio; > struct PARMS *Link; > }; > > #endif /* __VOLUME_H */ > > > > > /* > * Copyright 2003 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. > * > */ > /* "@(#) DSP/BIOS 4.90.280 12-12-03 (bios,dsk2812-a04)" */ >
/*************************************************************************** /
> /* > */ > /* V O L U M E . C > */ > /* > */ > /* Audio gain processing in a main loop > */ > /* > */ >
/*************************************************************************** /
> > #include <stdio.h> > > #include "volume.h" > > /* Global declarations */ > int inp_buffer[BUFSIZE]; /* processing data buffers */ > int out_buffer[BUFSIZE]; > > int gain = MINGAIN; /* volume control variable */ > unsigned int processingLoad = BASELOAD; /* processing routine load value
*/
> > struct PARMS str = > { > 2934, > 9432, > 213, > 9432, > &str > }; > > /* Functions */ > extern void load(unsigned int loadValue); > > static int processing(int *input, int *output); > static void dataIO(void); > > > /* > * ======== main ======== > */ > void main() > { > int *input = &inp_buffer[0]; > int *output = &out_buffer[0]; > > puts("volume example started\n"); > > /* loop forever */ > while(TRUE) > { > /* > * Read input data using a probe-point connected to a host file. > * Write output data to a graph connected through a probe-point. > */ > dataIO(); > > #ifdef FILEIO > puts("begin processing"); /* deliberate syntax error */ > #endif > > /* apply gain */ > processing(input, output); > } > } > > /* > * ======== processing ======== > * > * FUNCTION: apply signal processing transform to input signal. > * > * PARAMETERS: address of input and output buffers. > * > * RETURN VALUE: TRUE. > */ > static int processing(int *input, int *output) > { > int size = BUFSIZE; > > while(size--){ > *output++ = *input++ * gain; > } > > /* additional processing load */ > load(processingLoad); > > return(TRUE); > } > > /* > * ======== dataIO ======== > * > * FUNCTION: read input signal and write processed output signal. > * > * PARAMETERS: none. > * > * RETURN VALUE: none. > */ > static void dataIO() > { > /* do data I/O */ > > return; > } > > > > -- > _____________________ > Christopher R. Carlen > crobc@earthlink.net > Suse 8.1 Linux 2.4.19 >
Brad Griffis wrote:
> The watchdog probably wasn't disabled. Under the GEL menu their should be > an option to turn off the watch dog. > > Brad
Ah! That's certainly a good and obvious place to look. I'll see if I can figure out how to disable it tonight when I get home. Hmm, are you saying that the watchdog is enabled by default, and something must generally be done to disable it? Thanks for the input. Good day! -- ____________________________________ Christopher R. Carlen Principal Laser/Optical Technologist Sandia National Laboratories CA USA crcarle@sandia.gov
On Thu, 01 Jul 2004 07:44:36 -0700, Chris Carlen
<crcarle@BOGUS.sandia.gov> wrote in comp.dsp:

> Brad Griffis wrote: > > The watchdog probably wasn't disabled. Under the GEL menu their should be > > an option to turn off the watch dog. > > > > Brad > > Ah! That's certainly a good and obvious place to look. I'll see if I > can figure out how to disable it tonight when I get home. Hmm, are you > saying that the watchdog is enabled by default, and something must > generally be done to disable it? > > Thanks for the input. > > > Good day!
You did not mention which TI DSP you are using, but in prior posts you have talked about the 2812, and yes, indeed, the watchdog is enabled by default. In a real product where a watchdog was needed to reset the system to a default, fail-safe state if operation failed for any reason, having the watchdog off until the system operates successfully long enough to turn it on would be rather counter productive. By the way, if you have registered the CCS software from TI, download and install the 2.21.0 update. The IDE is much more stable and has fewer crashes. -- Jack Klein Home: http://JK-Technology.Com FAQs for comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html comp.lang.c++ http://www.parashift.com/c++-faq-lite/ alt.comp.lang.learn.c-c++ http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
"Chris Carlen" <crcarle@BOGUS.sandia.gov> wrote in message
news:cc180k12vb3@news2.newsguy.com...
> Brad Griffis wrote: > > The watchdog probably wasn't disabled. Under the GEL menu their should
be
> > an option to turn off the watch dog. > > > > Brad > > Ah! That's certainly a good and obvious place to look. I'll see if I > can figure out how to disable it tonight when I get home. Hmm, are you > saying that the watchdog is enabled by default, and something must > generally be done to disable it? >
You can also disable the watchdog in software. Here's how to do it from C: unsigned int *WDCR = (void *) 0x7029; // be sure to put the space between the quote and the first letter // of the command or it will be interpreted as a label instead // of an instruction asm(" EALLOW"); *WDCR = 0x0068; asm(" EDIS"); If you're just getting started with coding on the 281x I highly recommend you download the 281x C/C++ Header Files and Peripheral Examples: http://focus.ti.com/docs/toolsw/folders/print/sprc097.html There is a core set of code which gets used for properly initializing the DSP (i.e. stuff like setting up the peripheral interrupt expansion registers, etc.) plus they have examples for virtually every peripheral. Cheers, Brad
Brad Griffis wrote:
> You can also disable the watchdog in software. Here's how to do it from C: > > unsigned int *WDCR = (void *) 0x7029; > > // be sure to put the space between the quote and the first letter > // of the command or it will be interpreted as a label instead > // of an instruction > asm(" EALLOW"); > > *WDCR = 0x0068; > > asm(" EDIS");
That works. Thanks!
> If you're just getting started with coding on the 281x I highly recommend > you download the 281x C/C++ Header Files and Peripheral Examples:
> http://focus.ti.com/docs/toolsw/folders/print/sprc097.html > > There is a core set of code which gets used for properly initializing the > DSP (i.e. stuff like setting up the peripheral interrupt expansion > registers, etc.) plus they have examples for virtually every peripheral. Just did that. I was told about that stuff in a TI workshop in the F2812, but I'm just getting started with feeling my way through CCS. I have only worked with 8-bit micros before, so CCS is quite a bit more complicated, as is the CPU architecture. Thanks again. Good day! -- _____________________ Christopher R. Carlen crobc@earthlink.net Suse 8.1 Linux 2.4.19