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

cross mob

TRAVEO™ T2G: Using sin and cos functions in CYT2B7 - KBA236187

TRAVEO™ T2G: Using sin and cos functions in CYT2B7 - KBA236187

Infineon_Team
Employee
Employee
50 replies posted 25 likes received 25 replies posted

Version: **

Refer to the corresponding IDE document for using sin and cos functions in TRAVEO™ T2G CYT2B7. For IAR, refer to EWARM development guide. For GHS, refer to MULTI: Building application for Embedded Arm®.

A sample code for IAR is provided, to show different CPU loading using different option settings.

Standard library math functions for C/C++ are provided by IAR.

There are three different versions; default version, small version, and more accurate version. And, three different variant types are used; double, float, and long double.

The following table shows the sample code and the total time consumed for executing sin, cos, and tan functions for 100 times.

Sample code

Total time consumed for 100 times execution

    for (i = 0; i < 100; i++)

    {

      fresult = __iar_sin_smallf(f_test);

      fresult = __iar_cos_smallf(f_test);

      fresult = __iar_tan_smallf(f_test);

      f_test += 0.01f;

    }

Infineon_Team_0-1663939254978.png

Total time = 204us

    Cy_GPIO_Inv(USER_LED_PORT, USER_LED_PIN);   

    for (i = 0; i < 100; i++)

    {

      fresult = __iar_sin_accuratef(f_test);

      fresult = __iar_cos_accuratef(f_test);

      fresult = __iar_tan_accuratef(f_test);

      f_test += 0.01f;

    }

Infineon_Team_1-1663939376234.png

Total time = 384us

    Cy_GPIO_Inv(USER_LED_PORT, USER_LED_PIN);   

    for (i = 0; i < 100; i++)

    {

      double_result = __iar_sin_small(double_test);

      double_result = __iar_cos_small(double_test);

      double_result = __iar_tan_small(double_test);

      double_test += 0.01f;

    }

Infineon_Team_2-1663939394246.png

Total time = 2.62ms

    Cy_GPIO_Inv(USER_LED_PORT, USER_LED_PIN);   

    for (i = 0; i < 100; i++)

    {

      double_result = __iar_sin_accurate(double_test);

      double_result = __iar_cos_accurate(double_test);

      double_result = __iar_tan_accurate(double_test);

      double_test += 0.01f;

    }

 

Infineon_Team_3-1663939408345.png

Total time = 3.86ms

    Cy_GPIO_Inv(USER_LED_PORT, USER_LED_PIN);   

    for (i = 0; i < 100; i++)

    {

      long_double_result = __iar_sin_smalll(long_double_test);

      long_double_result = __iar_cos_smalll(long_double_test);

      long_double_result = __iar_tan_smalll(long_double_test);

      long_double_test += 0.01f;

    }

Infineon_Team_4-1663939419492.png

Total time = 2.64ms

    Cy_GPIO_Inv(USER_LED_PORT, USER_LED_PIN);   

    for (i = 0; i < 100; i++)

    {

      long_double_result = __iar_sin_accuratel(long_double_test);

      long_double_result = __iar_cos_accuratel(long_double_test);

      long_double_result = __iar_tan_accuratel(long_double_test);

      long_double_test += 0.01f;   

    }

    Cy_GPIO_Inv(USER_LED_PORT, USER_LED_PIN);   

Infineon_Team_5-1663939432291.png

Total time = 3.86ms

  

Since theTRAVEO™ CY2B7’s CM4 core includes a single precision FPU, for the CPU performance to use float is much better than double and long double variant types. Besides, small and accurate version also has a significant difference in the CPU performance.

Different version can be used based on the application requirement.

Note: This KBA applies to the following series of TRAVEO™ MCUs:

  • CYT2B series
0 Likes
174 Views