Digital Signal Processing Reference
In-Depth Information
// Sinegencasm.c Sine generation using DE calling ASM function
#include "dsk6713_aic23.h"
//codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
//set sampling rate
short y[3] = {0, 15137,11585};
//y(1)=sinwT (f=1.5kHz)
short A =12540;
//A=2*coswT * 2^14
short n = 2;
interrupt void c_int11()
//interrupt service routine
{
sinegencasmfunc(&y[0], A);
//calls ASM function
output_sample(y[n]);
return;
}
void main()
{
comm_intr();
//init DSK, codec, McBSP
while(1);
//infinite loop
}
FIGURE 5.24. C source program that calls an ASM function to generate a sine wave using
a difference equation ( sinegencasm.c ).
; Sinegencasmfunc.asm ASM function to generate sine using DE
;A4 = address of y array, B4 = A
.def _sinegencasmfunc
;ASM function called from C
_sinegencasmfunc:
LDH
*+A4[0], A5
;y[n-2]-->A5
LDH
*+A4[1], A2
;y[n-1]-->A2
LDH
*+A4[2], A3
;y[n]-->A3
NOP
3
;NOP due to LDH
MPY
B4, A2, A8
;A*y[n-1]
NOP
1
;NOP due to MPY
SHR
A8, 14, A8
;shift right by 14
SUB
A8, A5, A8
;A*y[n-1]-y[n-2]
STH
A8, *+A4[2]
;y[n]=A*y[n-1]-y[n-2]
STH
A2, *+A4[0]
;y[n-2]=y[n-1]
STH
A8, *+A4[1]
;y[n-1] = y[n]
B
B3
;return addr to call routine
NOP
5
;delays due to branching
.end
FIGURE 5.25. ASM function called from C to generate a sine wave using a difference
equation ( sinegencasmfunc.asm ).
Search WWH ::




Custom Search