Skip to content

[BUG] POW() #306

Description

@Candas1

Hi,

A user came across something weird when testing on a gd32 board.
A change in one of my last commit is making the main loop much slower, impacting motor control.

It seems the reason for the performance drop is the usage of pow() in the init of the voltage sense, although it's not even running in the main loop.... I still need to figure out why this happens, the gd32 is using a 4 years old gcc.

On stm32, I haven't noticed the performance drop, but I see another impact, which is the flash usage.
This is without the voltage sense:

RAM:   [=         ]   9.2% (used 4520 bytes from 49152 bytes)
Flash: [===       ]  27.3% (used 71484 bytes from 262144 bytes)

This is with volage sense:

RAM:   [=         ]   9.3% (used 4572 bytes from 49152 bytes)
Flash: [===       ]  29.5% (used 77332 bytes from 262144 bytes)

Now, as we are using the pow function only for powers of 2 and integers, I use this macro #define pwrtwo(x) (1 << (x)):

RAM:   [=         ]   9.3% (used 4572 bytes from 49152 bytes)
Flash: [===       ]  28.0% (used 73420 bytes from 262144 bytes)

So 1.5% less on a big chip (256Kb).

It seems pow() is used for the same purpose in MagneticSensorI2C and in MagneticSensorSPI

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions