| ??? 05/07/08 19:58 Read: times Msg Score: +1 +1 Good Answer/Helpful |
#154550 - toascii not what you want Responding to: ???'s previous message |
I have not used toascii but it appears that all it does is mask what is passed to it with 0x7F. I don't think this is what you want to do, I would suggest just making the function yourself. It seems you are wanting to convert hex values 0x00-0x09 to hex values 0x30-0x39 and hex values 0x0A-0x0F to hex values 0x41-0x46. Something like:
unsigned char Hex2Ascii(unsigned char HexValue)
{
HexValue &= 0x0F; // Mask the upper nibble
if (HexValue <= 0x09) // For numbers 0 - 9
{
return(HexValue + 0x30); // Return the ascii value for the digits
}
else // For letters A - F
{
return(HexValue + 0x37); // Return the upper case ascii values
}
}
Chris Bertrand said:
uart_transmit('B'); //the SBUF shows 0x42 as it should The reason this works is because uart_trasmit is actually being passed 0x42, the ascii value for the character B. |



