Own itoa

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Own itoa

1,470 Views
SCC
Contributor I
Hello I have a problem with converting int to char.
 
I don't have access to extras.h
And sprintf only givs back junk characters
I have also tried the union example that is placed here on the forum but no success
 
I have just simplefied the function to see what is going wrong but the problem is still there
 
void itoa() {
  unsigned int n = 12345;
  unsigned char i = 0;
  unsigned char s[7];
     
  RS232_Enable();
 
  do {
    s[i++] = (unsigned char)('0' + (n % 10));    // This works givs 54321 on RS232 or on LCD
    do{}while(RS232_SendChar(s[i-1]));
  } while ((n /= 10) > 0);
 
  s[i] = '\n';
      
  for(i=0;i<5;i++){
    do{}while(RS232_SendChar(s[i]));        // This doesent givs X4X2X   where X  is random
  }
}
 
And if i declare s[7] as static char i get 5X3X1  where X  is random
 
What am I doing wrong?
 
I use a 56F8357 and CW 8.1.1a build 7168
 
Hope someone could give me a helping hand because this is not what I should spend my time on.
 
Thomas 
Labels (1)
Tags (1)
0 Kudos
1 Reply

207 Views
trytohelp
NXP Employee
NXP Employee
Hi,
 
Can I suggest you to try with the last version CW for DSC 8.2 and compiler patch ?
 
You can download this version on our web site via the link:
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=CW-56800E-DSC
For details please have a look in:
http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=CW-56800E-DSC&tab=In-Depth_Tab
In the download tab you can download the Special Edition or the Evaluation.
The Special edition contains the special edition license limited to 32 kb of Code.
We recommend you to download the Evaluation edition.
A Professional Evaluation license is provided for first 30 days.
After 30 days the product will function at the Special Edition level.
If you need another version of the license please contact your local distributor.
You can purchase it directly from the web site too.
We changed the pricing and packaging structure for Codewarrior Tool.
Now there are 4 suites:
 special (free version)
 basic
 standard
 professional
Please refer to the link for details:
http://www.freescale.com/webapp/sps/site/overview.jsp?nodeId=0127262E703BC5
Go to the www.freescale.com and click on My Freescale.
After you were logged, select CodeWarrior Licensing under MY Secure Application.
In the new dialog you can manage your license file.
Keep in mind you can have several versions installed on the same PC.
There is only one restriction: install them on separate folder.
If you're using an old version, please backup your project before to try it with this new version.
If you will meet some compatibility issue you could back to the older version without problem.
 
Regards
Pascal
0 Kudos