exp,log and other math functions using CW for MCU Development Studio v10.6 and an MC9S08PA8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear community,
I am transfering a part of code from one MCU vendor (Atmel xmega32E5) to Freescale/NXP MC9S08PA8 MCU ,
and when I use the log function from math.h (i hope like other IDEs does) the MCU "hits" endless restarts.
If i comment this line, MCU does its supposed job without any issue and i can see an ADC result on debugger crystal clear.
unsigned int temp;
double ftemp;
void main(void)
{
System_Init(); //Initialise system hardware/software modules
for(;;)
{
temp=ADC_Get_Sample(CH11); //Read current channel ADC value (54us@8MHz)
ftemp=log(((10240000/temp) - 10000)); //Endless restart occurs - CRITICAL point
}
}
1) How /When do i update/include the "math.h" or similar (?) library header ?
2) Does this IDE support floats and doubles for "small ones" like the PA16 MCU?
(I have chosen at the beggining bareboard project with IIEE 64bit float support)
Best Regards,
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
FIY ,
SOLVED according to Edward Karpicz and Stanislav suggestion.
So to use logx,log , exp functions , include your <math.h> on your project and also go to
Project Settings->Linker_Files->Project.prm , open file with double click
and edit STACKSIZE from 0x80 (128bytes default size), to a bigger numer.
But beware, not to kill the entire RAM area by entering exotic hex number (For me it worked for 256bytes (0x100).
Cheers,
Ef
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Edward & Stanislav for your fast response ,
I will look into it as for math.h and modify(increase) the stack size of S08.
See how it goes, and get you feedback as soon as possible.
Cheers,
Tim

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Default stack size set in PRM file is too short for S08 math functions.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Efthymios,
it is possible to use the math functions in CW10.6. You need just include it:
#include <math.h>
It adds the math.h file from the installed CW package.
I hope this helps you.
Best Regards,
Stano.
