Hello ! I'm new here.

I try to write this equation for my DSP : Y(n) = 1/2 (X(n) + X(n-1)) . After assembling and lunch the code into the processor, there is no signal at the output of my DAC.

Below a part of the source code :

Code language : Assembler

Microprocessor : DSP 56374

with :

Y(n) : Output signal (TxBuffBase)

1/2 : Coefb0

X(n) : actual sample (Xn)

...

move #$0,b ; Init X(n-1) for the first loop

**AudioLoop**

jclr #RightRx,**x:**LRFlag,*

bclr #RightRx,**x:**LRFlag

move **x:**RxBuffBase,a ; <- ADC left input

; move x:RxBuffBase+2,b ; <- ADC right input (not use for the moment ...)

move a,**x:**(r1) ;saving Xn for the next loop

move r1,**x:**Xn

move #coefb0,r0 ; coefb0 declare as constant

move **x:**(r0),x1

add b,a ; a=X(n)+X(n-1)

move a,x0

mpy x0,x1,a ; a=1/2((X(n)+X(n-1))

move **x:**(Xn),b ; register b become X(n-1)

move a,**x:**TxBuffBase ; -> DAC left output

; move b,x:TxBuffBase+1 ; -> DAC right output (note use)

jmp AudioLoop

...

So what wrong with my code ? Does someone can help me pleas ?

note 1 : I'm a beginner.

note 2 : The complete source code is in the attachment.

**Original Attachment has been moved to: LPFn1_cs.asm.zip**

Hi Maxime,

I can see that your program has two components: the I/O and the math. I did not analyze your code to determine where your problem is, as I thought you needed to rewrite the math portion. As far as the I/O portion, I can address that later.

I can see that you are trying to implement an "exponential averager" with a coefficient of a=.5

Here is some code that I have for an exponential averager:

;

; Use the TachVoltage from the ESAI and filter it into x:TachoVelocity.

; We use the exponential-averager formula: Y(new) = a*X + (1-a)*Y(old)

; Where: X is the new sample, x:ESAI_TachVoltage

; Y(old) is the previous average, x:TachoVelocity

; and Y(new) is the new average.

;

TachFilter_a: equ .5 ;'a' modified for Maxime to .5

;

move x:ESAI_TachVoltage,X0 ;get tacho voltage read from the ESAI DAC

move x:TachoVelocity,Y0 ;get the previous value of the velocity

mpy #TachFilter_a,X0,A ; A = (a) * X

mac #1-TachFilter_a,Y0,A ; + (1-a) * Y(old)

nop ;pipeline stall

move A,x:TachoVelocity ;save filtered tacho voltage as motor velocity

;

A little explanation:

The actual averaging is done in only two instructions: a 'mpy' and a 'mac'.

Where you need to add two values, you can often use the "multiply-and-accumulate" instruction instead of an add. Much of the power of DSPs come from the 'mac' instruction, as many algorithms are based on adding successive products together.

Notice that in my above code, you can change the time-constant of the filter by changing the "TachFilter_a: equ .5" line. The smaller 'a' is, the more filtering you have. Since the sum of 'a' and '1-a' is 1, the filter has unity gain.

You should only use the address registers R0-R7, N0-N7 and M0-M7 when working with addresses. Remember that the ALU and the AGU are two independent computational units, with very different purposes.

The I/O is an independent issue.