Hello,
I am trying to convert unsigned short to a hex ascii string. It seems that sprintf() fails to do it.
fo example:
static void decimal_to_hex_string(USHORT hex_num, byte * pdecimal_number_str)
{
sprintf((char *)pdecimal_number_str, "%04lx", (USHORT)hex_num);
}
int main(void)
{
char pdecimal_number_str[5];
decimal_to_hex_string(0xBFCA, pdecimal_number_str);
// ------> After this line pdecimal_number_str is {0x62, 0xff,0xff, 0x45} while it should be {0x62, 0x66,0x63, 0x61}
}
I increased "Level of printf support" to full, and increased "Heap Size for C/C++" and "Set C system stack" to 0x1000 but still doesn't
work. I am usng CCS version 5.1.1.00031 and compiler version 4.0.0.
Is there any limitation for sprintf? Please note that this code works fine in visual studio.
thank you for your help.