- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I try to calculate some values of sin/cos on cpu1_main, but the return value of the function is not within my expectation.
#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#include "Ifx_Lwip.h"
#include <math.h>
#include <stdlib.h>
#include "Src/utils.h"
extern IfxCpu_syncEvent g_cpuSyncEvent;
extern float cos_test = 0;
extern float sin_test = 0;
void core1_main(void)
{
cos_test = cos(0);
printf("cos_test:%f",cos_test);
IfxCpu_enableInterrupts();
/* !!WATCHDOG2 IS DISABLED HERE!!
* Enable the watchdog and service it periodically if it is required
*/
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
/* Wait for CPU sync event */
IfxCpu_emitEvent(&g_cpuSyncEvent);
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);
while(1)
{
}
}
However, cos_test printf to be 2.000000, and 10000 in Debug view.
Should I link extra libraries such as libm?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I has changed Floating-Point from "2-Fast double" to "3-Fast single" fix this problem. But I still has a question? Is TC397 not supported "double precession"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Can you show me your cos function?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I just include <math.h> and use:
float cos_test = cos(0);
Shall I need to find the implement of cos function?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The assembly code is here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I has changed Floating-Point from "2-Fast double" to "3-Fast single" fix this problem. But I still has a question? Is TC397 not supported "double precession"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
no problem for cosine function which is C standard function. please see below screenshot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I has changed Floating-Point from "2-Fast double" to "3-Fast single" fix this problem. But I still has a question? Is TC397 not supported "double precession"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Only IEEE-754 single precision format is supported.