2024-01-07 06:55 AM
Hey,
I am developing a project in which the M7 core has CAN and USART communication which constantly communicates with components, the M4 core has Ethernet communication.
I was interested in checking what the rate of the main loop is, so I defined two variables of type double that perform the following operation in every main loop:
I display b7 in STM32CubeMonitor, and that's how I see how long it takes for 100K main loops, or how many main loops are performed per second.
Clock Configuration:
I did the test for the Core-M7 and the Core-M4, and these are the results:
Core-M7:
About 1.666M loops per second.
Core-M4:
About 60K loops per second.
The results are so far from each other (I expected a 2x ratio between them).
I started from the assumption that the Ethernet communication is the one that causes the slowing down, therefore I lowered the Ethernet communication and still got almost identical results.
I opened a new project (No code except the test) and ran the same test for each core, here are the results:
Core-M7:
About 500K loops per second, 3x slower at loop rate!!
Core-M4:
About 75K loops per second.
My questions:
1. The results don't make sense, the clock rate of M7 is 2 times the clock rate of M4, so why aren't the results about 2 times? Am I doing something wrong?
2. How can a code with two active communications (in M7) be 3 times faster than an almost empty code (in M7)?
3. How can it be that M4 is so slow (compared to M7)?
Thanks to the helpers!!
Solved! Go to Solution.
2024-01-07 07:21 AM
I suspect there are two main reasons:
2024-01-07 07:21 AM
I suspect there are two main reasons:
2024-01-08 01:05 AM
Thank you very much, you helped me!
If I have a lot of use of sin cos tan in my code, is there a way to optimize the operations? Maybe a library that supports this or some setting?
2024-01-08 06:45 AM
Not really. Use data types which are natively supported by the FPU. This means using floats on the CM4. There's no magic "make it faster" checkbox to hit here.