Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- STMicroelectronics Community
- STM32 MCUs
- STM32 MCUs products
- For certain complex fpu instructions from math.h l...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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
7 REPLIES 7

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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=4325
Tips, Buy me a coffee, or three.. PayPal Venmo

Up vote any posts that you find helpful, it shows what's working..

Up vote any posts that you find helpful, it shows what's working..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2014-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.

Tips, Buy me a coffee, or three.. PayPal Venmo

Up vote any posts that you find helpful, it shows what's working..

Up vote any posts that you find helpful, it shows what's working..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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 code- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

2014-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.
Tips, Buy me a coffee, or three.. PayPal Venmo

Up vote any posts that you find helpful, it shows what's working..

Up vote any posts that you find helpful, it shows what's working..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

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.

Up vote any posts that you find helpful, it shows what's working..

Related Content

- Collecting data from temperature sensor (I2C) and storing it in SRAM with less power consumption in STM32 MCUs Embedded software
- ISR function timing period issue in STM32 MCUs products
- DSB instruction for implementing delay after an RCC peripheral clock enabling in STM32 MCUs products
- Instruction Cache and Prefetch Buffer Settings are ignored if only LL library is used in STM32CubeIDE (MCUs)
- Getting HardFault and IBUSERR when jumping from bootloader to UART flashed application on STM32H7 in STM32 MCUs products