Forums

running compiling and link with asm and C tms320vc33

Started by male_uk00 May 14, 2004

I am having trouble with running my programmes

i have compiled the c programms with cl30 shell and linked with the
lnk30 ok but i am still unable to get them to run on the DSK.

can some body tell me the steps i need to take to get the programm
running on the boad tms320vc33 dsk

regards

Gez

/*FIRDMOVE.C - FIR FILTER MOVING THE DATA AND NOT POINTERS*/
#include "pcm3003.c" /*include AIC com routines */
#include "bp45coef.h" /*include coefficient file */
float DLY[N]; /*delay samples */

int data_in, data_out;

void filt(float *h,float *dly,int *IO_input,int *IO_output,int n)
{
int i, t;
float acc;
for (t = 0; t < n; t++)
{
asm(" idle"); /*wait for interrupt */
acc = 0.0;
dly[0] = *IO_input; /*newest input sample*/
for (i = 0; i < n; i++)
acc += h[i] * dly[i];
for (i = n-1; i > 0; i--)
dly[i] = dly[i-1]; /*update samples */
*IO_output = acc;
}
}

void c_int05()
{
data_in = UPDATE_SAMPLE(data_out);
}

main ()
{
int *IO_INPUT, *IO_OUTPUT;
IO_INPUT = &data_in;
IO_OUTPUT = &data_out;
AICSET_I();;
for(;;)
filt((float *)H,(float *)DLY,(int *)IO_INPUT,(int *)IO_OUTPUT,N);
}
AIC routine below here in another ======================================================================
#include <math.h>
#include "C3MMR.H"
#define S0xctrl 0x00000111 //
#define S0rctrl 0x00000111 //
#define TWAIT while (!(*S0_gctrl & 0x2)) /*wait till XMIT buffer
clear*/
#define XCLKSRCE ( 0 << 6 ) // 0=external 1= internal
#define RCLKSRCE ( 0 << 7 ) //
#define XVAREN ( 0 << 8 ) // VAREN 0 1
#define RVAREN ( 0 << 9 ) // FS ____---------_____
#define XFSM ( 0 <<10 ) // 0=burst 1=continuous
#define RFSM ( 0 <<11 ) //
#define CLKXP ( 1 <<12 ) //
#define CLKRP ( 1 <<13 ) //
#define DXP ( 0 <<14 ) //
#define DRP ( 0 <<15 ) //
#define FSXP ( 1 <<16 ) //
#define FSRP ( 1 <<17 ) //
#define XLEN ( 11b<<18 ) // 00=8 01 10$ 112
#define RLEN ( 11b<<20 ) //
#define EXTINT ( 0 <<22 ) //
#define EXINT ( 1 <<23 ) //
#define ERTINT ( 0 <<24 ) //
#define ERINT ( 1 <<25 ) //

#define SPBITS 32
#define BITSEL ((SPBITS/8)-1) // 0=8, 1, 2$ and 32 bits
// #define LP_STATUS (volatile long *) 0x80A000 // pointer CPLD
status bits

unsigned long S0gctrl_rst = XCLKSRCE|RCLKSRCE
|XVAREN|RVAREN
|XFSM|RFSM
|CLKXP|CLKRP
|DXP|DRP
|FSXP|FSRP
|EXTINT|EXINT|ERTINT|ERINT
|(BITSEL<<18)|(BITSEL<<20);

unsigned long S0gctrl_run =
0x0C000000
|XCLKSRCE|RCLKSRCE
|XVAREN|RVAREN
|XFSM|RFSM
|CLKXP|CLKRP
|DXP|DRP
|FSXP|FSRP
|EXTINT|EXINT|ERTINT|ERINT
|(BITSEL<<18)|(BITSEL<<20);

//==================================================
void InitPCM3003()

{

long T;

*T0_ctrl = 0; // Halt TIM0
*T0_count = 0; // Set counts to 0
*T0_prd = 3; // Set period
*T0_ctrl = 0x2C1; // Restart both timers
// - - - - - - - - - - - - - - - - - - - - -
*S0_gctrl = S0gctrl_rst; // global control
*S0_xctrl = S0xctrl; // transmit control
*S0_rctrl = S0rctrl; // receive control
*S0_xdata = 0; // DXR data value
*S0_gctrl = S0gctrl_run; // global control
T = *S0_rdata;
*S0_xdata = T; // DXR data value

asm(" or 080h,ST"); // Set overflow mode for fast saturate
}
void AICSET_I() /*configure AIC, enable TINTO */
{
InitPCM3003(); /*function to configure
AIC */
asm(" LDI 00000000h,IF"); /*clear IF Register */
asm(" OR 00000050h,IE"); /*enable EXINT0 CPU interrupt */
asm(" OR 00002000h,ST"); /*global interrupt enable */
}

int UPDATE_SAMPLE(int output) /*function to update sample */
{
int input; /*declare local variables
*/
TWAIT /*wait till XMIT buffer clear */
*S0_xdata = output; /*output sample*/
input = *S0_rdata; /*input sample*/
return(input); /*return new sample */



Hi

Your mail was chopped off a bit, so I needed to make some guesses.  What follows is not 100% working but you should be able to get going from here.  Here are some things to keep in mind.

- When you say 'Trouble' or 'Cant run' this can be a bit vague.  Did it sound bad, or did the program totally crash?

- You seemed to jump directly to the filter program.  A simple IN->OUT loop should be tried first.  There is an AIC loopback example written in C (LOOP_C3K.C) given with the DSK materials.  This will show you some ways to use the stereo codec.  There is also a stereo FIR examples (FIR_C3K.C) that also has an FIR filter generator built in.

- You
wrapped the function 'AICSET_I()' around 'InitPCM3003()'.  In it I noticed that you cleared the IF register.  Generally you dont want to do this as a serial port underrun could stop the flag setting mechanism. 

- The linker command was not given.  Where did the linker put your code and data?  Generate a MAP file to see where things have been placed.  Also, looking at the map file you may find a section or two that have not been given allocation information.  In these cases those sections are placed sequentially beginning at address 0x0, and that wont work.

- Some functions like
UPDATE_SAMPLE() appear before a prototype has been defined.  In these cases the compiler assumes the inputs and outputs are integer.  Your function is int in/out so you should be OK in this case, but be warned.

- If you place a line or two of code within the ISR or main loop that toggles an external pin (like an IOF line) you can use this to see if the loop is running.

To get something working...

- There was no interrupt branch table so your interrupts where going nowhere

- You dont need TWAIT (something was wrong here)

- The AIC receive data is left justified, while transmit is right justified

- This is a stereo codec.  You will need to poll the LRCIN bit either from CPLD status or as INT1 flag after setting the enable bit.  As is, a simple loopback will maintain L/R matching but you could see the L/R channels cross over once in awhile.  When you add the filter, things wont work.  The reason is that you are pumping both L and R through one filter and outputing one output to both L and R.  IE it sounds strange.

Hope this helps

Best regards
Keith Larson

DSP and Analog Consulting

home.comcast.net/~klarsondsp /*FIRDMOVE.C - FIR FILTER MOVING THE DATA AND NOT POINTERS*/

#include "pcm3003.h"
#include "pcm3003c.c"     /*include AIC com routines      */
//#include "bp45coef.h"     /*include coefficient file      */
#include "C3MMR.H"

#define BP0 asm(" .global BREAKPOINT_0"); asm("BREAKPOINT_0: nop");
#define BP1 asm(" .global BREAKPOINT_1"); asm("BREAKPOINT_1: nop");

#define N 16
int UPDATE_SAMPLE(int output);
void AICSET_I(void);

float DLY[N]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // delay samples
float   H[N]={0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0}; // avg of 5 samples

volatile int  data_in, data_out;

void filt(float *h,float *dly,volatile int *IO_input,volatile int *IO_output,int n)
{
  int i, t;
  float acc;
  for (t = 0; t < n; t++)
  {
    asm("          idle");           /*wait for interrupt */
    acc = 0.0;
      dly[0] = *IO_input;              /*newest input sample*/
      for (i = 0; i < n; i++)
            acc += h[i] * dly[i];
    for (i = n-1; i > 0; i--)
      dly[i] = dly[i-1];             /*update samples     */
    *IO_output = acc;
  }
}
void c_int05(void) // function to update sample
{
  *S0_xdata =      data_out;  // output sample
  data_in   = *S0_rdata>>12;   // input sample
}
#define IDLE asm(" idle");
void main(void)
{
  volatile int *IO_INPUT, *IO_OUTPUT;
  int ramp =0;
  IO_INPUT = &data_in;
  IO_OUTPUT = &data_out;
  InitPCM3003(3);
  asm(" or 10h,IE");
  for(;;)
  {
    IDLE
    //*IO_OUTPUT = *IO_INPUT;  // simple loop back
    filt((float *)H,(float *)DLY,IO_INPUT,IO_OUTPUT,N);
  }
}

/*===================================================================
  Install the XINT/RINT ISR branch vectors
 ====================================================================*/
  asm(" .global _c_int05 ");
  asm(" .sect  \"BRTBL\"");  /* secondary branch table */
  asm(" br    _c_int05  ");  /* XINT0                  */
  asm(" br    _c_int05  ");  /* RINT0                  */
  asm(" .text           ");