Thursday, April 30, 2020

Linear Algebra data type - ARM defination

There are some date type which we will use to linear algebra:

+ Floating Point.
+  The Q15 value
For example: Q15 vector absolute value.
void arm_abs_q15(
  q15_t * pSrc,
  q15_t * pDst,
  uint32_t blockSize);

* The Q15 value -1 (0x8000) will be saturated to the maximum allowable positive value 0x7FFF.   

So,what is q15 valule???
 /**
   * @brief 16-bit fractional data type in 1.15 format.
   */
  typedef int16_t q15_t;

If your signal is presently centered around 0x8000 (32768) then just invert bit 15 (15..0) of your data.  This is what the AtoD on the dsPIC does.  In this way what used to be 0x0000 will be 0x8000 and what used to be 0xFFFF will be 0x7FFF.

Now your data will range from 0x8000 (-1.0) to 0x0000 (0.0) to 0x7FFF (1-(1/32768)).  0x7FFF doesn't quite make it to 1.0.

Even though you can have a data type of "fractional" if you include the dsp.h file, it really is an "int" as far as the compiler is concerned.  So no, I don't believe you can display it as fractional.  The fractional data type will work with the dsp functions in the library or any inline functions you design using the DSP portion of the dsPIC as long as you know it is being treated as fractional.

You need to convert them to a range of -1.00<n<1.00, multiply by 32768, then convert to hex. For instance, 0.500 is 0x4000.


And other data type:
/**
   * @brief 8-bit fractional data type in 1.7 format.
   */
  typedef int8_t q7_t;

  /**
   * @brief 16-bit fractional data type in 1.15 format.
   */
  typedef int16_t q15_t;

  /**
   * @brief 32-bit fractional data type in 1.31 format.
   */
  typedef int32_t q31_t;

  /**
   * @brief 64-bit fractional data type in 1.63 format.
   */
  typedef int64_t q63_t;

  /**
   * @brief 32-bit floating-point type definition.
   */
  typedef float float32_t;

  /**
   * @brief 64-bit floating-point type definition.
   */

  typedef double float64_t;

No comments:

Post a Comment

Back to Top