I am working on a project on which i need to send data over USART to terminal. I need to display the data as the numeric value (0-255) of the char (which collected from the EEPROM
i have managed to send the char as is to the terminal (using Putty or TerMite) My problem starts where the value of the char is non-printable
That's why i will need to convert the value of the char to numeric
Example: when the data acquired from the EEPROM is 0x31 my routine will send '1' but i will need to send '049' or '49' to the terminal
void SendToSer(void) {
unsigned char Looper;
for (Looper=EEPROM_START;Looper<EEPROM_END;Looper++){
ReadEEPROM(Looper); //returns ReadResult
Write1USART((char) ReadResult); //Sends the ASCII
ClrWdt();
}
}
Thanks,
The sprintf as jolati suggested can be a good work horse in some situations or, even better, snprintf if it is available for your version of C18. Both routines follow the standard printf formatting (ex. https://en.wikipedia.org/wiki/Printf_format_string).