Part Number: TMS320F28034
I have a function that mulitiplies an _iq18 type with a large integer. I need both the integer and fractional portion of the result for subsequet computations. Currently the code looks something like this:
int32 counts = 320000; _iq18 scaler = _IQ(0.667); int32 intResult = _IQ18mpyI32int(scaler, counts); _iq18 remainder = _IQ18mpyI32frac(scaler, counts);
According to documentation on the IQ library, _IQNmpyI32int() and _IQNmpyI32frac() each take over 20 cycles to complete. This code is located in a tight loop that is continuously repeated and so I would like to cut down on the number of execution cycles as much as possible. Is there any way to optimize this code? I suspect that _IQNmpyI32int() and _IQNmpyI32frac() are performing very similar computations; so if there is someway I could "combine" them, I feel like I could squeeze out just a little bit more CPU time.
I thought about using the plain _IQNmpyI32() and then extracting the integer and fractional components out of the result. However, `counts` frequently evaluates to a very large number, so that the product of `counts` and `scaler` would exceed the range of an _IQ18 type.