I primarily code FIR and IIR filters using the fir_fr16 and iir_fr16 library functions (all of my Blackfin code is in C). I'm coming from the golden era of ADSP-21xx assembly.
First question: I have an FIR filter where one of the coefficients is -36127. On the old 218x processor, I'd break the coefficient into two values (-18063 and -18064 in this case) and write a custom assembly function that would not increment the input data pointer until after the second multiply.
Is there a library function to handle coefficients greater than 32767 (or less than -32768)? Or am I going to have to modify the library function to handle this particular case? I'm not well-versed in Blackfin assembly.
Second question: This FIR filter also has an output scaling factor (in this case a multiply of 4 but will be coded as a left shift of 2). I'd like to round the accumulator and then perform the shift so as not to lose (in this case) 2 bits of precision. Is there a library function to handle this?
e.g. if we have an accumulator value of:
0x00 0123 AD72
we'd add 0x00 0000 2000 to round the LSB of our pre-shifted value, resulting in 0x00 0123 CD72
and then left shift 2, giving us our final 16-bit value in the high word, 0x00 048F 35C8
where we store 0x048F. This is obviously much better than simply shifting 0x0123 by 2, yielding 0x048C and losing precision.
Am I going to have to modify the library function to perform this arithmetic?
Any help, tips, advice would be appreciated.