2024-09-30 08:48 PM
I am trying to move some some working "domestic" DSP routines to the CMSIS library in hopes of them executing faster. The first one is a fairly simple 64-tap FIR filter on 160 samples of 16-bit fixed point data. I generated it using the Tfilter website, a pretty neat website.
I'm following the example from Phil's Lab (https://www.youtube.com/watch?v=lDskXTR6psY) with the variation that I'm including the libarm_cortexM7l_math.a library instead of either floating point library. I'm using current versions of STM32CubeIDE (1.16.1) and the H7 Library (1.11.2).
I get a compile error ... (my).elf uses VFP register arguments, ... libarm_cortexM7l_math.a(arm_fir_q15.o) does not.
For starters, I'm only using fixed point DSP, so kinda weird, but even so I am compiling with Floating Point ABI set to hardware (-mfloat-abi=hard), so this seems not quite right. The compiler should be using "real" floating point even though I am not.
Just for debugging I tried setting the ABI to software but get linker errors complaining about unsupported assembly instructions. I also tried the mix HW/SW option and while that compiles without errors, I get a runtime exception in the CMSIS library.
The hopefully relevant code snippets are:
(Variables)
static arm_fir_instance_q15 Voice_Instance = {0} ;
static q15_t Voice_Coefs[VOICEFILTER_TAP_NUM] = {0} ;
static q15_t Voice_State = 0 ;
(init)
int i = 0 ;
/* Examples say I need to reverse the filter taps - but aren't the */
/* coefs symmetric? */
for (i=0;i<VOICEFILTER_TAP_NUM;i++) Voice_Coefs[i]=voice_filter_taps[VOICEFILTER_TAP_NUM-i-1] ;
arm_fir_init_q15(&Voice_Instance,VOICEFILTER_TAP_NUM,Voice_Coefs,&Voice_State,160) ;
DSPing
arm_fir_q15(&Voice_Instance,in,out,160) ;
The only big thing in the Phil's Lab example that I'm not doing is the firbuf thing that is the working buffer. That doesn't seem to exist with the fixed point routines.
Most of the forum posts on this issue seem to be folk compiling for the software ABI and linking to the CMSIS library expecting the HW ABI. While not using floating point now, I'd like to be able to in the future, so would like it enabled and that is what the CMSIS library is expecting I think.
Thanks in advance for any pointers. This is my first attempt at using the CMSIS DSP libraries, so expecting it is some kind of user/newbie error. I'm looking forward to seeing how much faster they are.
will
2024-10-01 09:44 AM
OK, it looks like it was two different issues clouding things.
1) On a lark I just used the single precision floating point CMSIS library, realizing I didn't really know what the library without "fp" in the name really was. Using that library instead resolved the compile-time errors while still compiling with -mfloat-abi=hard. I hope it did so correctly and I'm still using real floating point ABI's, not just now agreeing to use virtual ones.
2) I did indeed need that full working buffer mentioned in the Phil's Lab example. I misread the API call and it wasn't a pointer to a variable, it was supposed to be a pointer to an array as mentioned in the video. That was definitely a newbie oversight!
Things work and a 160 sample, 64-tap FIR filter run takes 53us instead of 146us, almost 1/3 the time--yay!
will