Hello everybody,

I am trying to write a program for amplitude meter for ADSP-21364.

I modified analog talkthru IN-OUT ASM where I put an easy LED blink method.

in my ISR is:

r10=dm(RXSP0A);

nop;

r1 = 0xd50000;

comp(r1,r10);//r10,r1

if ge jump skipled1; //le, ge

bit tgl FLAGS FLG8;

nop;nop;

skipled1:

So this I use to blink with led when input value r10 reach the value r1.

Now I want to set the r1 value (treshold) automatically,

using mean value (W-Value) and std (standard deviation)

Accordign to manual ADSP-2100 and DSP Guide i decided to

combine C and asm code and using mean & rms signal processing functions

or to rewrite:

100 CALCULATION OF THE MEAN AND STANDARD DEVIATION

110 '

120 DIM X[511] 'The signal is held in X[0] to X[511]

130 N% = 512 'N% is the number of points in the signal

140 '

150 GOSUB XXXX 'Mythical subroutine that loads the signal into X[ ]

160 '

170 MEAN = 0 'Find the mean via Eq. 2-1

180 FOR I% = 0 TO N%-1

190 MEAN = MEAN + X[I%]

200 NEXT I%

210 MEAN = MEAN/N%

220 '

230 VARIANCE = 0 'Find the standard deviation via Eq. 2-2

240 FOR I% = 0 TO N%-1

250 VARIANCE = VARIANCE + ( X[I%] - MEAN )^2

260 NEXT I%

270 VARIANCE = VARIANCE/(N%-1)

280 SD = SQR(VARIANCE)

290 '

300 PRINT MEAN SD 'Print the calculated mean and standard deviation

310 '

320 END

from DSP Guide - chapter 2

But I now I don´t know if I can combine c and asm (in C i can use mean & rms functions)

and both how to rewrite code above for asm.

Can anyone help me telling which of two ways will be more efficent?

If anyone has these things rewrited and functional for asm and can post them

it will be great.

Thank for your help.

Kind regards,

Martin S. (roland)

Hi Martin,

To be able to call a C function from an assembly code, the project should be created as a C project. Thus, it may not be possible for you to use the assembly talkthrough code as it is for calling a C library function.

I would therefore suggest you to use the C talkthrough code available at path "<installation_drive>\Program Files\Analog Devices\VisualDSP 5.0\213xx\Examples\ADSP-21364 EZ-KIT Lite\Block Based TalkThru (C)". If required, you could modify this code to sample based talkthru. This modification could probably be easier than writing the "mean" and "stadard deviation " code in assembly.

Please let me know if you need further help on this.

Thanks,

Mitesh