Tool/software: Code Composer Studio
I have the following lines in my code:
struct system_info {
unsigned int battery_gain;
int battery_offset;
} SystemInfo;
unsigned int read_battery(void);
return (((unsigned long)read_battery() * SystemInfo.battery_gain) >> 10) + SystemInfo.battery_offset;
When this line is compiled, I get int32 = int32 x int32 multiplication, calling __mpyl in the library.
I tried to follow the instructions in multiplication guide (www.ti.com/.../spra683):
return (((unsigned long)(unsigned int)read_battery() * (unsigned long)(unsigned int)SystemInfo.battery_gain) >> 10) + SystemInfo.battery_offset;
I still get the same multiplication call __mpyl.
How can I use the more efficient multiplication int32 = int16 x int16?