I am trying to use a short filter (8 floating point multiplications and additions) to a 4 khz signal but the chip cant't stand it. 我在论坛上看到有一个浮点数library: arm_cortexM0l_math.lib. How do I include it into the project?
How do I select CMSIS DSP software component from keil? BTW I made some measurements and seems that the floating point multiply takes about 5 microseconds. Is it so?
When building the project I get the following: .\out\template.axf: Warning: L6304W: Duplicate input file .\out\system_armcm0.o ignored. ..\..\..\..\scatterfiles\scatterfile_common.sct(327): error: L6235E: More than one section matches selector - cannot all be FIRST/LAST. Not enough information to produce a SYMDEFs file. Not enough information to list image symbols. Not enough information to list the image map. Finished: 3 information, 1 warning and 1 error messages. ".\out\template.axf" - 1 Error(s), 1 Warning(s). Target not created
When the package was installed I see 2 new items in the project: CMSIS which includes the library Device which includes startup_ARMCM0.s and system_ARMCM0.c
I think thare there are 2 files system_ARMCM0.c
Do you have an example of a project that uses the floating point library?
Hi MT_Dialog I removed the package "device" so all I have is CMSIS with the library inside. The project building succeeds but I don't think the software is accessing the library. How do I force the floating point to be routed to this library instead of the built-in math library?
You don't need to use the DSP library to meet your deadlines. Just make sure you use float calculations and not double calculations. Constants like 1.0031 is a double literal and not a float literal. Write 1.0031f instead, otherwise in each iteration your float/uint16_t values will first be converted to doubles, then double calculations are done, and when the result is stored in fddd, the result is converted back to a float. So you should write like this:
Hi Rony,
Try to select the CMSIS DSP software component from keil, for your project andinclude the arm_math.h file.
Thanks MT_dialog
How do I select CMSIS DSP software component from keil?
BTW I made some measurements and seems that the floating point multiply takes about 5 microseconds.
Is it so?
Hi Rony,
Please follow the link from keil website to check how to add software packs in keilhttp://www.keil.com/support/man/docs/uv4/uv4_ca_packselect.htm
About the floating point operations from a quick test i can verify that it takes about 5 microsec for a floating point multiplication.
Thanks MT_dialog
I have tested the timing with the following code without the keil library:
uint32_t time0;
float fddd, yn1,yn2,yn3,yn4;
uint16_t ddd,xn1,xn2,xn3,xn4;
time0=lld_evt_time_get();
for (int i=0; i<100; i++) {
ddd=17;
fddd=0.1672*ddd -0.6687*xn1+1.0031*xn2-0.6687*xn3+0.1672*xn4;
fddd=fddd+0.7821*yn1-0.68*yn2+0.1827*yn3-0.0301*yn4;
xn4=xn3; xn3=xn2; xn2=xn1; xn1=ddd;
yn4=yn3; yn3=yn2; yn2=yn1; yn1=fddd;
}
uint32_t time1=lld_evt_time_get();
when I check time1-time0 I get around 100.
This means that the filter calculation (8 multiplications, 8 additions) takes around 600 microseconds.
Am I wrong?
Installed the package as you suggested.
When building the project I get the following:
.\out\template.axf: Warning: L6304W: Duplicate input file .\out\system_armcm0.o ignored.
..\..\..\..\scatterfiles\scatterfile_common.sct(327): error: L6235E: More than one section matches selector - cannot all be FIRST/LAST.
Not enough information to produce a SYMDEFs file.
Not enough information to list image symbols.
Not enough information to list the image map.
Finished: 3 information, 1 warning and 1 error messages.
".\out\template.axf" - 1 Error(s), 1 Warning(s).
Target not created
When the package was installed I see 2 new items in the project:
CMSIS which includes the library
Device which includes startup_ARMCM0.s and system_ARMCM0.c
I think thare there are 2 files system_ARMCM0.c
Do you have an example of a project that uses the floating point library?
Hi MT_Dialog
I removed the package "device" so all I have is CMSIS with the library inside.
The project building succeeds but I don't think the software is accessing the library.
How do I force the floating point to be routed to this library instead of the built-in math library?
You don't need to use the DSP library to meet your deadlines. Just make sure you use float calculations and not double calculations. Constants like 1.0031 is a double literal and not a float literal. Write 1.0031f instead, otherwise in each iteration your float/uint16_t values will first be converted to doubles, then double calculations are done, and when the result is stored in fddd, the result is converted back to a float. So you should write like this:
uint32_t time0;
float fddd, yn1,yn2,yn3,yn4;
uint16_t ddd,xn1,xn2,xn3,xn4;
time0=lld_evt_time_get();
for (int i=0; i<100; i++) {
ddd=17;
fddd=0.1672f*ddd -0.6687f*xn1+1.0031f*xn2-0.6687f*xn3+0.1672f*xn4;
fddd=fddd+0.7821f*yn1-0.68f*yn2+0.1827f*yn3-0.0301f*yn4;
xn4=xn3; xn3=xn2; xn2=xn1; xn1=ddd;
yn4=yn3; yn3=yn2; yn2=yn1; yn1=fddd;
}
uint32_t time1=lld_evt_time_get();
That gives time1=21 which means each iteration takes 131 microseconds which meets the deadline of 250 microseconds for a 4 kHz filter.
God bless you Joacimwe.
Works like a champ.
Have a great and peacefull new year