Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static q15_t my_sin_q15( q31_t x)
- {
- /* Calculate the nearest index */
- int32_t index = (uint32_t)x >> FAST_MATH_Q31_SHIFT;
- /* Calculation of fractional value */
- q15_t fract = (x - (index << FAST_MATH_Q31_SHIFT)) >> 7;
- /* Read two nearest values of input value from the sin table */
- q15_t a = my_sinTable_q15[index];
- q15_t b = my_sinTable_q15[index + 1];
- /* Linear interpolation process */
- q31_t sin = (q31_t)((0x8000 - fract) * a) + ((q31_t)fract * b);
- return sin >> 15;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement