#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Convert a decimal to hex and use the hex value to set output pins high

Member Posts: 1
edited February 2017

Hi,
I am taking an integer like 32, converting it to a hex number, and concatenating it with 0X to produce a char output = 0X1F. I then use "output" to set output pins on MSP30 high.
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". I don't understand how to fix this. Can someone help please.

`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 *output; 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(output, string ); strcat(output, hex); P1OUT = output ; }`