![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Kauty Guest
|
Every character is seen as acsII .......why?? |
Posted: Fri Feb 17, 2006 12:11 pm |
|
|
Hi all,
Is it me or is this just annoying and very silly.
I am trying to output hex values out the serial pins. sounds simple.
so i am using printf or fprintf to do so:
one would thing if you typed :
for(i=0x0;i<0x7F;i++){
printf("%x",i);
delay_ms(300);
}
i was thinking, this will give me the hex value of the numbers 0-128 on the serial TX line. instead it is giving me hex values of 30-7F, becuase it treats variable i as an ascii character......is that normal to anyone?? or i am alittle oblivious about something.
I will appreciate any help |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Fri Feb 17, 2006 12:40 pm |
|
|
You are I think misunderstanding something.
Hex, _is_ an ASCII format. The number '7F',is the two ASCII characters '37', and '46'. It sounds as if you are running a program at the other end, which is taking raw binary, and turning this into it's hex representation. hence your value gets converted twice!.
Try outputing the character using putc, as:
Code: |
for(i=0x0;i<0x7F;i++){
putc(,i);
delay_ms(300);
}
|
This sends the raw value, and your program at the other end, will then do the required conversion.
In fact you are only dealing with raw numbers, and hex need not come into it at all. So:
Code: |
for(i=0x0;i<127;i++){
putc(,i);
delay_ms(300);
}
|
Will give exactly the same result...
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
kauty Guest
|
|
Posted: Fri Feb 17, 2006 12:53 pm |
|
|
You would trhink after those year i would have it striaght!
You are absolutely correct and thanks for your quick help |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|