gwdeveloper 275 Posted October 31, 2011 Share Posted October 31, 2011 The FR5739 has the MPY32 hardware multiplier. I would like to use this to speed up the division of a floating point number, float/int. From what I assume, in place of X/Y, I can use X*(1/Y) and use the hardware multiplier. From http://www.ti.com/lit/an/slaa329/slaa329.pdf it would seem that I lose the remainder when doing the division. Is there a faster way to do floating point division with integers but retain accuracy? Currently, I am using the DMA to speed up ADC conversions but then losing cycles during the division. I know I can use the DMA to directly enter the data into the MPY32 registers but then I'll still lose accuracy. Quote Link to post Share on other sites
SirZusa 34 Posted October 31, 2011 Share Posted October 31, 2011 x / y multiply x by 10000 and truncate it - so you get an integer out of the float with 4 decimals, then do a normal integer - integer - division ... and in the last step divide it by 10000 to get the result - i dont know if it is faster - but you can give it a try something like this (untested) float x = 1.234567; int y = 7; int z = x * 10000; float result = z / (y * 10000); gwdeveloper 1 Quote Link to post Share on other sites
gwdeveloper 275 Posted October 31, 2011 Author Share Posted October 31, 2011 I'll give it a shot. Gotta reset CCS after figuring out how to make it count CPU cycles. I never though to multiply it by 10000 to make it a whole number first. That may actually make it easier to use the hardware multiplier and still speed things up a bit. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.