Well, the first thing to bear in mind is that the serial port does not care what the value is, you can send any 8-bit data through it.
This is code I use to convert a 4-bit binary number to ASCII
Code:
//*******************************************************************************
// convert a binary value to it's equivalent ascii hex character
unsigned char BinToAsc(unsigned char BinValue)
{
BinValue &= 0x0F;
if(BinValue > 9) BinValue += 7;
return(BinValue + '0');
}
As you can see, it's a function but you can work out the math it uses. For 8-bit values like the one you get from ADRESH, call it with:
SendToSerial(BinToAsc(ADRESH >> 4));
SendToSerial(BinToAsc(ADRESH));
Use your own serial routine instead of 'SendToSerial()'.
For sending an 8-bit binary value as decimal ASCII, try this:
Code:
Value = ADRESH;
Temp = Value / 100;
SendToSerial(Temp + '0'); // send hundreds
Value -= (Temp * 100);
Temp = Value / 10;
SendToSerial(Temp + '0'); // send tens
Value -= (Temp * 10);
SendToSerial(Value + '0');
You can also do it using string functions:
sprintf(ASCIIString,"%03d",ADRESH);
then send 'ASCIIString' to the serial port.
Brian.