Hi, im new here, and Im doing a proyect which happens that i need to change a string to integer.
On C eclipse works fine however on Freescale doesnt do anything.
Pleace help
I create a new proyect apart just to see ATOI working properly. I was able to see that the variable "number" changes from 4 to cero, as if nothing got atoi and if I uncoment the atof line i geet the error Symbol strtod ... is undefined.
Please advice (version of my codewarrior is V6.3 build 9279
This is the code:
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char y[] @0x0068 ="12";
char f[] @0x0070 ="143.343";
int number @0x0060 =4;
double flot;
void main(void) {
EnableInterrupts; /* enable interrupts */
/* include your code here */
for(;;) {
__RESET_WATCHDOG(); /* feeds the dog */
number=atoi((const char*)y); /// also like this doesnt work : number=atoi(y);
//flot = atof((const char*)f);
} /* loop forever */
/* please make sure that you never leave main */
}
Solved! Go to Solution.
Hi Gus,
You can use function atoi() directly in your application.
See attached example project for reference.
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Gus,
You can use function atoi() directly in your application.
See attached example project for reference.
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I have another doubt.
Your code works fine under MC9S08DZ60, but on the proyect im working on which happens to be 08QG8 doesnt work there
why is that ?
Greetings
Hi
1. QG8 default project allocates 0x40 bytes RAM to stack. while atoi and atof is very memory consuming. so you need increase the stack size.
2. use atof, you need use floating support.
see attached demo code and screenshot.
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks a lot Zhang!
I owe you a beer ! :smileyhappy:
You are welcome ! :-)
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Jennie!
I have a new quetion for you :smileygrin:
Hi Gus,
please create a new thread for the new questions. I will check. thanks!
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks a lot Jennie :smileyhappy:
you are welcome! :-)
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank you Zhang! now it works fine atoi ! thx a lot
By the way , do you happen to know why im getting strtod in file main.c.o is undefined ? in case i want to use atof ?