Quantcast
Channel: Processors forum - Recent Threads
Viewing all articles
Browse latest Browse all 17527

OMAPL138 assembly FIR filter works great in debug, but breaks after optimization

$
0
0

I've been working on creating a 256 tap adaptive FIR filter sampling at 48 kHz,

My setup is as follows:

I'm using the OMAP L138 board with a c674x processor. I am processing audio via McASP and servicing an interrupt (interrupt 4) to process the audio and output it. This portion is written entirely in c. In order to get better performance (using a circular buffer) I have linked the filtering function call in my interrupt to a assembly code stored in my L2 cache. I also have my coefficients and previous input arrays stored in permanent memory in L2 cache. My L2 caching mode is setup to behave as regular memory so that data is not overwritten. The C interrupt code is as follows:

interrupt void interrupt4(void) // interrupt service routine
{
float r,l = 0;
// Read in the input...
l = (float)(input_left_sample());
r = (float)(input_right_sample());

l = filteradapt(l, r);

out_data.channel[LEFT] = (uint16_t)l;
out_data.channel[RIGHT] = (uint16_t)r;
output_sample(out_data.uint);


return; //return from interrupt
}

My filteradapt assembly call is as follows:

.title "filteradapt.sa"
.def _filteradapt
.text
.global _filteradapt
.global _h
.global _x
.global _ptr

_h .usect "h_array", 1024, 4
_x .usect "x_array", 1024, 4
_ptr .usect "pointer", 4, 4

_filteradapt: .proc A4,B4, B3 ;took out A8
.reg offset, sum, a, b, count,d, error, beta, h, ptr
.reserve B5, B6
mv B4, d
;setup circular buffer
mvk 0x0400, B0 ; using B5 for addressing and using bk0 for block
mvklh 0x0009, B0 ;set block size for 2^(9+1) = 1024 (using bk0)
mvc B0, AMR

;load in registers
mvkl _x, B5
mvkh _x, B5
sub B5, 4, B6 ; remember h(end) is x(-1) because h is placed at 0x11800000 and x is placed at 0x11800400
mvkl _ptr, ptr
mvkh _ptr, ptr
ldw *ptr, offset
sub offset, B5, offset
addab B5, offset, B5

;store input
stw A4, *B5++

mvk 0, sum
mvk 0, A6
mvk 0x100, count
; begin FIR filter - remember h comes before x in memory
convolve: ldw *B5++, a; load the input
ldw *B6--, b; load the filter coefficients

mpysp a, b, A6
|| addsp A6, sum, sum
[count] sub count, 1, count
[count] b convolve

;store pointer
stw B5, *ptr

addsp A6, sum, sum

;send output
mv sum, A4

.endproc A4, B3
b B3

This code is simply performing an FIR filter. No adapting happening yet. (written in linear assembly). I know this is painful to look at, but hopefully this gives some insight into my problem. When I run this code in debug mode (optimizer turned off) this thing runs perfectly happy in real-time. Once I turn on the optimizer (in either debug or release mode) it quits working all-together. Ironically, I am able to step into my ISR while debugging and I can see that the output I get from my filter is correct. The problem, I believe, is that the program ceases to use the ISR after the first pass. What could be causing this problem?


Viewing all articles
Browse latest Browse all 17527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>