Bug in GFLIB_AtanYX_F16

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bug in GFLIB_AtanYX_F16

1,367 Views
raul10
Contributor I

I'm using the CM4 version of the RTCESL library. The function GFLIB_AtanYX_F16 has an error flag as output type which the documenation claims to be a bool_t type that is 16 bit wide.

However, it seems the routine writes a 32 bit value to the error address. I've checked this with library versions 4.4 and 4.5 - both have the same behaviour.

Could you please check if other routines of the library using the bool_t type correctly as 16 bit value.

Thank you.

Tags (1)
0 Kudos
7 Replies

1,174 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Sorry for the later reply.

From GFLIB_AtanYX_F16 function declaration, the return value is frac16_t:

pastedImage_1.png

The use example also using frac16_t variable to receive the result:

pastedImage_2.png

Wish it helps.


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,174 Views
raul10
Contributor I

Hi Mike,

I was asking about bErrFlag. The function writes a 32 bit value to this variable but the documentation says it is a 16 bit bool type. 

0 Kudos

1,174 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I couldn't generate the error flag with GFLIB_AtanYX_F16 () function.

So, I don't find there with pass 32 bit value to the error address.

Could you guide me how to generate an error situation? Thanks.

pastedImage_1.png


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,174 Views
raul10
Contributor I

Hi Mike,

You don't need to generate an error because the function writes to the error flag if there is no error, too.

To simulate the error situation you need to declare bErrFlag as a 32-bit value like in this example:

static frac16_t f16Result;
static frac16_t f16Y, f16X;
static uint32_t bErrFlag;

void main(void)
{
   bErrFlag = 0x12345678:

   f16Y = FRAC16(0.9); /* f16Y = 0.9 */
   f16X = FRAC16(0.3); /* f16X = 0.3 */

   /* f16Result = atan(f16Y / f16X); f16Result * 180 => angle [degree] */
   f16Result = GFLIB_AtanYX_F16(f16Y, f16X, (bool_t *)&bErrFlag);
}

You will see bErrFlag is set to 0 by the function. This should not be the case if the function returns the error flag as a 16 bit bool type.

0 Kudos

1,174 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I debug into the GFLIB_AtanYX_F16() function and find it call STR instruction to transfer error flag.

Please check the address 0x1FFFC9E6 was written 32-bit data with STR instruction.

pastedImage_1.png

I also check the ARM Cortex M4 STR instruction, which store 32bits value to R2 register.

Thank you let us know that, I will report this issue to software team.


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,174 Views
raul10
Contributor I

Hi Mike,

I found the same as you: the 32 bit STR instruction is used for clearing the error flag as well as for seting it.

Regards

0 Kudos

1,174 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Thank you for the guide.

I could regenerate your mentioned issue.

The uint32_t bErrFlag variable was totally changed with 16-bit value.

I need to discuss with software team about this issue.


Have a great day,
Mike

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos