Part Number: TMS320F28027
Other Parts Discussed in Thread: CONTROLSUITE
Tool/software: TI C/C++ Compiler
The following code is used in the kit. It is to average 8 numbers. I have question on the constant used and why the shift is 15. I understand these are very elementary questions.
// BoxCar Averages - Input Raw samples into BoxCar arrays
//----------------------------------------------------------------
Uint32 HistPtr, temp_Scratch; // Temp here means Temporary
int16 Gui_Vout; // Q9
int16 K_Vout; // Q15
K_Vout=17050;
temp_Scratch=0;
for(i=0; i<8; i++) temp_Scratch = temp_Scratch + Hist_Vout[i];
Gui_Vout = ( (long) temp_Scratch * (long) K_Vout ) >> 15;
The "for loop" sums the 8 values in the array Hist_Vout. What is the function "(long) K_Vout )"? How is the IQ math used here? Why shift 15?
I run the code with a Xcode on a Mac to get a better understanding of how it works, but could not under stand the "K_Vout" and the shift 15. Is the "(long) used to because of the multiply?
Any help would be great value.
Thanks