This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
hello, I explain to you with extension my problem, I have a string in hexadecimal and I want to pass it to ascii, I can not think of another idea to go through it and do an if with each of the data assigning the value that equals, but for this I need to know how go through that string and then how to assign value 1 of the string to the corresponding value. If you know any way to transform the chain to ascii without so much code, please do me a favor, thanks. I'm trying in the example of SDK nfc-reader to pass the string that returns me in hexadecimal pass it to ascii, in case you can help me exactly with the case I'm playing, thanks.
Regards
You really did not give me enough details, but: #define SIZE 16 uint8_t hexdata[SIZE]; char ascii_str[2*SIZE+1]; char table[16] = {'0', '1', '2', '3', /* ...*/ 'e', 'f'}; int char_idx=0; int i; uint8_t nibble; for (i=0; i<SIZE; i++) { nibble = ((hexdata[i] >> 4) & 0x0F); // top 4 bits ascii_str[char_idx++] = table[nibble]; nibble = (hexdata[i] & 0x0f) // bottom 4 bits ascii_str[char_idx++] = table[nibble]; } ascii_str[char_idx] = '\0'