I am working on firmware for an embedded device. I want to send an array of hex char values over a serial port. Is there an easy way to convert a value to ASCII hex?
For example, if the array contains 0xFF, I want to send the ASCII string "FF" or for the hex value 0x3B. I want to send "3B".
How is this usually done?
I already have serial send functions so that I can do this ...
char msg[] = "Send this message";
SendString(msg);
and the SendString function calls this function for each element in the passed array:
int SendU( int c)
{
while(U1STAbits.UTXBF);
U1TXREG = c;
return c;
}
I am looking for a function that will allow me to do this ...
char HexArray[5] = {0x4D, 0xFF, 0xE3, 0xAA, 0xC4};
SendHexArray(HexArray);