2014-12-22 08:00 AM
For example:
output = asinf(num1)*0/PI;
//result = 60
output = output/2.0;
//result = 30
output
= output * PI /0;
//result = 0.5235987 radians (30 degrees0
output = tanf(output);
//result = sqrt(3)/3
output = output /
sqrt
(3);
//result = 1/3
output = output * 6.0 + 9.9;
//result = 9
#math.h #lmgtfy #armcm4.h-arm_math.h
2014-12-22 08:30 AM
Use DWT_CYCCNT?
[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Duration%20of%20FLOAT%20operations&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=4325]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FDuration%20of%20FLOAT%20operations&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=43252014-12-22 08:34 AM
I'd also recommend precomputing constants to convert from/to degrees and radians, so that you use MULTIPLICATION instead of DIVISION, ie use reciprocals.
2014-12-25 04:59 PM
Thanks for the idea. But, I do not have the mcu currently with me.
I wanted to calculate the number of cycles it took to complete a certain program on STM32F4 which I did quite a while ago. So, can you suggest any other way. I later found that, each compiler has a different implementation internally for functions of the math.h library. I used Cocox CoIDe.2014-12-25 05:03 PM
That is a viable option when you want to reduce the number of cycles for the program to complete, right?
With FPU enabled I guess multiplication would take lesser cycles than division. I want to find out how many cycles(time) a certain mcu(stm32f4 in this case) would take to reach a certain point of code2014-12-25 05:36 PM
Unless you have access to a gate level simulation, the best you can do is review ARM documentation as to what range of cycles the instructions will take, and walk through your code.
The exact number of cycles will likely depend on the numbers (mantissa/exponent) being used in a specific operation.2014-12-28 09:40 AM
Thanks for the solution. Other than manually computing.
If I don't have the MCU and I have the code and the compiler- Can I use DWT_CYCCNT in the compiler and get a result for the respective functions?2014-12-28 02:58 PM
You can use the method to count any group of code or subroutines. Best to have interrupts disabled as it will count those instructions also.