Using ARM’s CMSIS DSP Library: arm_recip_q15

I’ve begun using ARM’s free CMSIS DSP library on a project, but the documentation is quite sparse. So, I’ve started documenting how to use these functions as I learn by trial and error. The first function is: arm_recipt_q15.

static __INLINE uint32_t arm_recip_q15(
q15_t in,
q15_t * dst,
q15_t * pRecipTable)
uint32_t signBits = 0;
return (signBits + 1);

This function takes the reciprocal of a fixed point variable, in. The format of the input, in, is in the Q Format 2.14, not 1.15 that the name implies. For example, 0.25 is represented as 0x1000, 0.5 is represented as 0x2000. RecipTable is a Lookup Table within the ARM library. The function returns two values, dst and signBits. although dst is declared a q15_t, it is not. It is a 16bit data type with the number of sign bits designated in the other return value, signBits. Crafty, huh? Here are some examples.

arm_recipt_q15(0.25) returns 3.998.

signBits = arm_recip_q15(0x1000,&out,armRecipTableQ15);
signBits = 0x3
out = 0x7FFE

The sign bits are “011” and the fraction is “0x1FFE”. That is 3 + (8190 / 8192) = 3.9998 which is approximately 4.

That concludes this quick example of ARM’s function arm_recip_q15. Here is the link to ARM’s library.

UPDATE: I found this documentation [pdf] for TI’s processors helpful in understanding their functions which translated to ARM’s.

Leave a Reply

Your email address will not be published. Required fields are marked *