Tool/software: TI C/C++ Compiler
I am taking an integer like 32, converting it to a hex number, and concatenating it with 0X to produce a char X= 0X1F. I then use X to set output pins on P1OUT.
The below code does what I just explained. When I run this, I get the following error: a value of type "char *" cannot be assigned to an entity of type "unsigned char".
Is there any better way to concatenate 0X with a Hex number to set P1.0?
char h[17] = "0123456789ABCDEF";
static uint8_t num = 32; //decimal number to be converted to hex
char hex[32];
static uint8_t Quo; // Quotient
static uint8_t Rem; //Remainder
char *string = "0X";
char *X;
hex[0] = '\0';
while (num !=0)
{
Quo = num/16;
Rem = num % 16;
memmove (&hex[1], hex, strlen(hex)+1);
hex[0] = h[Rem];
num = Quo;
//concatinate
output= malloc(strlen(string)+strlen(hex)+1);
strcpy(X, string );
strcat(X, hex);
P1OUT = output ;
}