Friends of Community,
In my current project, I need to limit a sinusoidal wave (in any point), and for this I need to use the ACOS function. I implement the next code in a S08RNA16 MCU:
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include <math.h>
/* User includes (#include below this line is not maintained by Processor Expert) */
void main(void)
{
/* Write your local variable definition here */
float x, y;
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
x = 0.0;
y = cos(x);
x = _M_PI/2;
y = cos(x);
x = _M_PI;
y = cos(x);
x = 2*_M_PI;
y = cos(x);
x = 1.0;
y = acos(x);
x = 0.9;
y = acos(x);
x = -1.0;
y = acos(x);
/* Write your code here */
/* For example: for(;;) { } */
for (;;)
{
}
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;){}
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
}
When the control of program reach the point to calculate the ACOS of 0.9, the Simulator of CodeWarrior 11.1 goes to this screen (rtshc08.c) and stop (the program does not calculate the ACOS for that value):
#pragma NO_EXIT
static void _FADD_Common(void) {
asm {
JSR _UNPACK_k_to_K;
JSR _UNPACK_j_to_L;
JSR _FADD_K_is_K_plus_L;
JSR F_NORMK;
_SRET
JSR _PACK_K_to_k; /* returns itself */
}
}
My question is: Why am I finding this problem for a valid number (0.9) for the ACOS function?
I appreciate an orientation for solve this problem.