📄 fixpoint_leaky_lms.c
字号:
//
// Project: Experiment 10.7.3 AEC using C55x Intrinsics - Chapter 10
// File name: fixPoint_leaky_lms.c
//
// Description: This AEC uses the fixed-point leaky LMS algorithm
//
// For the book "Real Time Digital Signal Processing:
// Implementation and Application, 2nd Ed"
// By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
// Publisher: John Wiley and Sons, Ltd
// Tools used: CCS v.2.12.07
// TMS320VC5510 DSK Rev-C
//
#include "fixPoint_leaky_lms.h"
void fixPoint_leaky_lms(DTALK *dtObj, LMS *lmsObj)
{
DTALK *dt=(DTALK *)dtObj;
LMS *lms=(LMS *)lmsObj;
long temp32,ue;
short j,n,sign, step;
short *x,*w;
n = lms->order;
w = &lms->w[0];
x = &lms->x[0];
// Update data delay line
for(j=n-1; j>0; j--)
{
x[j] = x[j-1];
}
x[0] = lms->in;
// Get adaptive filter output - equation (7.2.19)
temp32 = (long)w[0] * x[0];
for(j=1; j<n; j++)
{
temp32 += (long)w[j] * x[j];
}
lms->out = (short)((temp32+ROUND)>>15);
// Compute error term - equation (7.2.20)
lms->err = lms->des - lms->out;
if(!lms->freez)
{
long temp32a;
// Coefficients update - equation (7.4.5)
ue = (long)(((lms->err * (long)lms->mu)));
temp32a = dt->farInPowM >>15;
if ( temp32a >=32767)
{
temp32a =32767;
}
else if (temp32a <=1)
{
temp32a=1;
}
sign =1;
if (ue <0)
{
ue = -ue;
sign = -1;
}
if (ue < dt->farInPowM)
{
step = div_l(ue, (short)temp32a);
}
else if (ue >= (dt->farInPowM<<1))
{
step = (short)(ue>>14);
}
step = step*sign;
for(j=0; j<n ; j++)
{
temp32 = (((long) w[j])<<15);
temp32 += (long) ((long)step * x[j]);
w[j] = (short)((temp32+ROUND) >>15);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -