MATH linear rotation mode

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hi,

Is there any example for MATH linear rotation mode?
I tried to implement the following code for multiplication, however it is not clear how to interpret arguments and the result.
The arguments and the results are two's complement but in which format? (0Q23, 1Q22, etc..)


#include

#include "XMC1300.h"

#define XMC_MATH_Q8_15(x) ((XMC_MATH_Q8_15_t)(((x) >= 0) ? ((x) * (1 << 15) + 0.5) : ((x) * (1 << 15) - 0.5)))

int32_t XMC_MATH_Linear_XMulY(int32_t x, int32_t y)
{
uint32_t result;

MATH->STATC = 0U; /* Clear register */
MATH->CON = (uint32_t) XMC_MATH_CORDIC_OPERATING_MODE_LINEAR + \
(uint32_t) XMC_MATH_CORDIC_ROTVEC_MODE_ROTATION;
MATH->CORDY = 0U; /* Clear register */
MATH->CORDZ = ((uint32_t) y) << MATH_CORDZ_DATA_Pos;
MATH->CORDX = ((uint32_t) x) << MATH_CORDX_DATA_Pos;
result = ((int32_t)MATH->CORRY) >> MATH_CORRY_RESULT_Pos;
return ((int32_t) result);
}

int main(void)
{
int a;
uint32_t result;
uint32_t x;
uint32_t y;

x = XMC_MATH_Q8_15(0.5);
y = XMC_MATH_Q8_15(0.5);

result = XMC_MATH_Linear_XMulY(x, y);
a = 1;

while(1);
}
0 Likes
3 Replies
User11506
Level 2
Level 2
Hi jsmith65

There is some description of the XMC MATH functions in the help file of the the XMC_Peripheral_Library_v2.1.6

I am not sure if you have already checked that. I hope it helps.

Regards.

Paul.
0 Likes
Not applicable
I think no description for this mode.
0 Likes
chismo
Employee
Employee
First like received
Hello,

The CORDIC's linear rotation mode is probably not useful since the CPU core can easily calculate Y+X*Z.

From the XMC1300 reference manual, section 7.3.4 on CORDIC Co-processor data format:
- X and Y are in two's complement and can be in any format as long as they are the same.
- Z must be in 4Q19 format.

Regards,
Min Wei
0 Likes