CORDIC angle format

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

cross mob
Not applicable
Hi,

To calculate sin(30 degree) I have to call XMC_MATH_CORDIC_SinNB with 0x155555.
To calculate sin(-30 degree) I have to call XMC_MATH_CORDIC_SinNB with 0x955555 ? So simply negate the sign bit?


#include

#include "XMC1300.h"

//30*8388608/180 = 0x155555 : CORRY=0x3FFFFE00
//sin(-30) = 0x955555 : CORRY=0xC0000100
//14.47751219*8388608/180 = 0xA4B8C : CORRY=0x1FFFFC00 (arc sin = 0.25)

#define N 3

int main(void)
{
/* variable initialization */
XMC_MATH_Q0_23_t angle = { 0x155555, 0x955555, 0xA4B8C };
XMC_MATH_Q0_23_t calculation_result;

/* sine of angle calculation */
// CON.ROTVEC=1, CON.MODE=1 (rotation mode and circular mode)
for (int i=0; i XMC_MATH_CORDIC_SinNB(angle);

while(XMC_MATH_CORDIC_IsBusy()); // wait for calculation to end
calculation_result = XMC_MATH_CORDIC_GetSinResult();
}

while(1);
}

0 Likes
1 Reply
User7282
Level 4
Level 4
Hello,

I think that you have to use -30/180*2^23, corresponding to 0xFFEAAAAA.
0 Likes