Reply by timhust May 23, 20052005-05-23
I am now doing the project on Tms320vc5409, so it could not do as what
you said? Any more suggestion? I really appriate with it!~

Reply by Axey May 20, 20052005-05-20
         Yes you are right that doing a graduate project is to do it
for ourself. Let me tell you what the fact is....Well we are already
finished with the project without the real time implementation but it
was our interest to implement it in real time so that we get a better
exposure to real time implementation which is ruling todays world in
every arena. Thank you all of you for the reply..... It will surely be
very useful for the very little time we have...

Reply by Axey May 20, 20052005-05-20
Probably our defination for real time for the present project would be
the first option of yours....

Reply by Charles Krug May 20, 20052005-05-20
On 19 May 2005 23:52:52 -0700, Axey <girish.tp@rediffmail.com> wrote:
> Well, this is a graduation project. what we need right now is > just a fair idea to implement our project in real time. The concept is > needed, its just that we are looking for. Once we get a fair idea how > to implement in real time we can convert that concept in C-code to > implement.
How are you defining "RealTime?" There's a definition of realtime that means "Take a temperature reading every day at noon." There's another definition that means, "play the movie with no data glitches and try not to have any dropouts greater than 1/30 second." There's still another that means, "If you don't respond to this interrupt within 250ms, things blow up (occasionally literally). All three are "real time" by a reasonable definition. The third is MUCH harder to achieve than the first two. What you need to do is the same thing we always need to do in optimization: 1. Profile your code to determine where it's taking too much time. 2. Optimize the critical loops It's a lot easier to ask for suggestions on three lines of code versus a lengthy uncommented program listing.
Reply by Axey May 20, 20052005-05-20
  Thanks for your reply with the code...  We will surely check it out
and send out the results and i think you can check out the suggetions
by the experts given right in this discussion... Thanks once again...

Reply by Randy Yates May 20, 20052005-05-20
Randy Yates <yates@ieee.org> writes:
> [...] >>> sum= sum+ ((w[k]*d[k])>>15);
PS: Using C's integral promotion rules, the proper way to do this would be sum = sum + (((long)w[k] * d[k]) >> 15); -- % Randy Yates % "Maybe one day I'll feel her cold embrace, %% Fuquay-Varina, NC % and kiss her interface, %%% 919-577-9882 % til then, I'll leave her alone." %%%% <yates@ieee.org> % 'Yours Truly, 2095', *Time*, ELO http://home.earthlink.net/~yatescr
Reply by Randy Yates May 20, 20052005-05-20
AntiSPAM_g9u5dd43@yahoo.com writes:

> Not gone through the code in detail, but if you right shift a short > int by 15 bits, you won't have much left. > >> short sum=0; >> short d[FILTERLENGTH]={0}; // reference input >> short w[FILTERLENGTH]; //filter weight >> sum= sum+ ((w[k]*d[k])>>15);
You're warning on this potential issue is prudent, but in the case of overflow the compiler designers are free to do what they please. In TI's case they do the expected (and easiest) thing, compute the product in the accumulator (with all 40 bits available) and then shift and store back into a 16-bit int. So the warning is good, but the code, in this case, will work properly. --Randy
> > > > > On Fri, 20 May 2005 03:17:00 -0500, > timhust@126-dot-com.no-spam.invalid (timhust) wrote: > >>Hi >>I am doing the same project as you. And I have got some c code on >>dsk. >>But there are still some problems so that the result is not the same >>as the ideal one. I will give you the c code and maybe you can find >>where the problem is. Whatever the result is,please tell me! My >>e-mail address is: timhust@126.com. >> >>c code: >>static short LCh,RCh; >>#define FILTERLENGTH 32 >> >>static unsigned short RFlag = 0;//Data receive flag, 1 data got >> asm( " ssbx intm "); >> CPU_ini();//sysclk=10MHz*10,12.5M*8,2004-12-08 >> >>interrupt void aic_rint0() // >>{ >> >> LCh = *MCBSP0_DRR1; >> RCh = *MCBSP0_DRR2; >> >> //*MCBSP0_DXR1 = 0x8000;//test only >> >> //*MCBSP0_DXR2 = 0x8000;//test only >> RFlag = 1; >>} >>void Algor_1(void) >>{ >> while(1) >> { >> while(!RFlag); >> RFlag = 0; >> DATAIO(); >> } >>} >>//First algorithm demo function,Digital Loop Back >>void DATAIO(void) >>{ >> short mu=1638 ; //stepsize >> short d[FILTERLENGTH]={0}; // reference input >> short w[FILTERLENGTH]; //filter weight >> short primary ; //including s+n >> short k; >> short sum=0; >> short filtered=0; >> short temp; >> short j=0; >> >> if(j==0) >> { >> for(k=0;k<FILTERLENGTH;k++) >> { >> w[k]=0x7fdf; //the initial value of the coefficients is >>0.999 (0x7fdf) >> } >> j=1; >> } >> >> for(k=0; k<FILTERLENGTH-1;k++) // update the values in the >>reference array >> { >> d[k]=d[k+1]; >> >> } >> >> d[FILTERLENGTH-1]=LCh; >> primary=RCh; >> >> >> for(k=0; k<FILTERLENGTH;k++) >> { >> sum= sum+ ((w[k]*d[k])>>15); >> } >> filtered=primary- sum; >> >> temp=mu*filtered>>15; >> for(k=0;k<FILTERLENGTH;k++) >> { >> w[k]=w[k] + ((d[k]*temp)>>15); >> } >> >> >> >> >>//app algorithm >>*MCBSP0_DXR1 = (primary<<16) + filtered; >> *MCBSP0_DXR2 = (primary<<16) + filtered; >>} >> >
-- % Randy Yates % "So now it's getting late, %% Fuquay-Varina, NC % and those who hesitate %%% 919-577-9882 % got no one..." %%%% <yates@ieee.org> % 'Waterfall', *Face The Music*, ELO http://home.earthlink.net/~yatescr
Reply by May 20, 20052005-05-20
Not gone through the code in detail, but if you right shift a short
int by 15 bits, you won't have much left.

> short sum=0; > short d[FILTERLENGTH]={0}; // reference input > short w[FILTERLENGTH]; //filter weight > sum= sum+ ((w[k]*d[k])>>15);
On Fri, 20 May 2005 03:17:00 -0500, timhust@126-dot-com.no-spam.invalid (timhust) wrote:
>Hi >I am doing the same project as you. And I have got some c code on >dsk. >But there are still some problems so that the result is not the same >as the ideal one. I will give you the c code and maybe you can find >where the problem is. Whatever the result is,please tell me! My >e-mail address is: timhust@126.com. > >c code: >static short LCh,RCh; >#define FILTERLENGTH 32 > >static unsigned short RFlag = 0;//Data receive flag, 1 data got > asm( " ssbx intm "); > CPU_ini();//sysclk=10MHz*10,12.5M*8,2004-12-08 > >interrupt void aic_rint0() // >{ > > LCh = *MCBSP0_DRR1; > RCh = *MCBSP0_DRR2; > > //*MCBSP0_DXR1 = 0x8000;//test only > > //*MCBSP0_DXR2 = 0x8000;//test only > RFlag = 1; >} >void Algor_1(void) >{ > while(1) > { > while(!RFlag); > RFlag = 0; > DATAIO(); > } >} >//First algorithm demo function,Digital Loop Back >void DATAIO(void) >{ > short mu=1638 ; //stepsize > short d[FILTERLENGTH]={0}; // reference input > short w[FILTERLENGTH]; //filter weight > short primary ; //including s+n > short k; > short sum=0; > short filtered=0; > short temp; > short j=0; > > if(j==0) > { > for(k=0;k<FILTERLENGTH;k++) > { > w[k]=0x7fdf; //the initial value of the coefficients is >0.999 (0x7fdf) > } > j=1; > } > > for(k=0; k<FILTERLENGTH-1;k++) // update the values in the >reference array > { > d[k]=d[k+1]; > > } > > d[FILTERLENGTH-1]=LCh; > primary=RCh; > > > for(k=0; k<FILTERLENGTH;k++) > { > sum= sum+ ((w[k]*d[k])>>15); > } > filtered=primary- sum; > > temp=mu*filtered>>15; > for(k=0;k<FILTERLENGTH;k++) > { > w[k]=w[k] + ((d[k]*temp)>>15); > } > > > > >//app algorithm >*MCBSP0_DXR1 = (primary<<16) + filtered; > *MCBSP0_DXR2 = (primary<<16) + filtered; >} >
Reply by May 20, 20052005-05-20
Gee, I thought the point of doing a "graduate project" 
was to do it yourself.  

On 19 May 2005 23:52:52 -0700, "Axey" <girish.tp@rediffmail.com>
wrote:
> Well, this is a graduation project. what we need right now is >just a fair idea to implement our project in real time. The concept is >needed, its just that we are looking for. Once we get a fair idea how >to implement in real time we can convert that concept in C-code to >implement. > We knowing the concept of LMS algorithm we wrote our own code, it >just works in Borland C. The problem arrived when we wanted to >implement it to real time, we did change the code relevant to the real >time implementation. One more thing is the number of samples is >limited, the Borland C or the Code composer software cant take more >than 1000 samples. Any more details, do ask me. Thank you for your >reply.... What we need is a working concept or probably the C-code >iself...
Reply by timhust May 20, 20052005-05-20
Hi
I am doing the same project as you. And I have got some c code on
dsk.
But there are still some problems so that the result is not the same
as the ideal one. I will give you the c code and maybe you can find
where the problem is. Whatever the result is,please tell me! My
e-mail address is: timhust@126.com.

c code:
static short LCh,RCh;
#define FILTERLENGTH 32

static unsigned short RFlag = 0;//Data receive flag, 1 data got
	asm( " ssbx intm ");
	CPU_ini();//sysclk=10MHz*10,12.5M*8,2004-12-08

interrupt void  aic_rint0() //
{  

   LCh =  *MCBSP0_DRR1;
   RCh =  *MCBSP0_DRR2;
     
   //*MCBSP0_DXR1 = 0x8000;//test only
   
   //*MCBSP0_DXR2 = 0x8000;//test only
   RFlag = 1;
}
void Algor_1(void)
{
 while(1)
 	{
 while(!RFlag);
 RFlag = 0;
 DATAIO();
 	}
}
//First algorithm demo function,Digital Loop Back
void DATAIO(void)
{
    short mu=1638 ; //stepsize
    short d[FILTERLENGTH]={0};  // reference input
    short w[FILTERLENGTH];      //filter weight 
    short primary ;      //including s+n
    short k;
    short sum=0;
    short filtered=0;
    short temp;
    short j=0;

    if(j==0)
    {
       for(k=0;k<FILTERLENGTH;k++)
        {
          w[k]=0x7fdf; //the initial value of the coefficients is
0.999 (0x7fdf)
        }
      j=1;
    } 
     
    for(k=0; k<FILTERLENGTH-1;k++) // update the values in the
reference array
    {
     d[k]=d[k+1];
    
    }
  
    d[FILTERLENGTH-1]=LCh;
    primary=RCh;
   
    
    for(k=0; k<FILTERLENGTH;k++)
    {
        sum= sum+ ((w[k]*d[k])>>15);
    }
    filtered=primary- sum;
  
    temp=mu*filtered>>15;
    for(k=0;k<FILTERLENGTH;k++)
    {
     w[k]=w[k] + ((d[k]*temp)>>15);
    }

    


//app algorithm
*MCBSP0_DXR1 = (primary<<16) + filtered;
 *MCBSP0_DXR2 = (primary<<16) + filtered;
}