This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello there,
iam using the 28335 together with CCS v6.1.2.
My goal is to implement a motor control application. To stay independent of fix/float target i used the TI-DMC library provided macros.
Everything works good and now i am trying to optimize my code for speed. During the process some questions came up, which i hope the community can help me with.
Q1
For the angle i use a normalization to a GlobalQ number (2pi corresponds to '1' ; pi corresponds to 0.5 , -pi corresponds to -0.5).
The angle needs to be wrapped at various stages of my routine and i decided to let it run from [-0.5....0.5] in iq-math format.
So the wrapping looks like this at the moment:
#define wrap_angle(angle) \
if (angle > _IQ(0.5)) \
angle -= _IQ(1.0); /* wrap upper */ \
else if (angle < _IQ(-0.5)) \
angle += _IQ(1.0); /* wrap lower */ \
Global Q is set to 24 at the moment.
Now iam trying to substitute this with a bit mask ... my ideas are the following: as my format is global Q = 24 my mask
would look like this
mask = (2^24 - 1 ) = 16777215 = 0x00FF FFFF
and the wrapping with a mask an a unipolar signal could look like this
angle &= mask
But i dont think this is going to work with bipolar signals.
So the question is, how could such a wrapping algorithm with if branches stated above be substituted with bit masks for bipolar signals?
Q2
This question relates to the different CCS compiler versions for the C2000 family and their optimization features/impact.
right now my main ISR takes about ~50us to compute. When i try different compilers and optimization settings this wont change
a lot (max 1-2us faster) - even with the "highest possible" optimization settings.
i use the Compiler version 16.9.0 LTS with optimization level 1....5
Is this (new) compiler still suitable for my target 28335 (which was launched some years ago) or should i go
back to some older compiler and try optimization options there?
Is there any general opmization advice to speed the code up? Ive already done the following:
- pack 95% of the functions into ram via "ramfunc" attribute (i still have plenty of ram left)
- inline smaller functions
- use dmc with macros
- use the optmizer at compiler level (see above)
- "clean up" code, avoid unneccessary operations & summarize them
Thanks for the help in advance!
regards
Hey , thanks for your advice.
right now , my solution works good and i was just trying to improve my code for speed, since this "wrapping logic" occurs ~20 times per isr. Maybe someone knows how much the saving potential for these instructions is at the 28335 ? (is it worth it? i mean like >5us or something like that? i dont think so..)
i think it doesnt hurt me a lot but a "natural" overflow would be nice since i wouldnt need to care about it in code anymore (and the qep module resets my angle signal on index event anyway).
Ill mark the question answered. As for optimization, i found a good TI document. If you could give another comment on the saving potential i'd bee happy.
Regards