1.4.2.69 DSP_VectorDivC Function

Divides the first N elements of inVector by a constant divisor, and stores the result in outVector.

Description

void DSP_VectorDivC(_Q16 *outVector, _Q16 *inVector, _Q16 divisor, int N);

Divides each element of the first N elements of inVector by a constant, divisor. The output is stored to outVector. Both vectors and the scalar are _Q16 format, which is 32-bit data with 15 bits for the integer and 16 bits for the fractional portion. If values exceed maximum or minimum they will saturate to the maximum or minimum respectively.

Preconditions

The pointers outdata and indata must be aligned on 4-byte boundaries. This function uses the Div function from the LibQ library.

That library must be compiled as part of the project.

Parameters

outdata pointer to destination array of elements (_Q16)

indata pointer to source array of elements (_Q16)

divisor scalar divisor for the input vector (_Q16)

N number of samples (int)

Returns

None.

Remarks

This function uses the Microchip PIC32MZ LibQ library to function. The user must include that library and header file into the design in order to operate this function. For more information on the Div function see the LibQ documentation for _LIBQ_Q16Div.

Example

int divNum = 4;

_Q16 divScalar = 0x00020000; _// 2.0_

_Q16 inDivVec[8] = {0x08000000, 0xfffc0000,0x00024000,0x00100000,0x00038000,

0x00400000,0xfffe0000,0x00058000};

_// 2048, -4, 2.25, 16, 3.5, 64, -2, 5.5_

_Q16 outDivVec[8] = {0};

DSP_VectorDivC(outDivVec, inDivVec, divScalar, divNum);

_// outDivVec = 0x04000000, 0xFFFFE0000, 0x00012000, 0x00080000, 0, 0, 0, 0_

_// 1024.0, -2.0, 1.125, 16.0, 0, 0, 0, 0_

C

void  DSP_VectorDivC (_Q16 * outVector , _Q16 * inVector , _Q16 divisor , int  N );