[Solved] How to change a char to ASCII form?


Buff_Y[2] = (Y / 100) + 0x30;
Buff_Y[1] = (Y / 10) % 10+0x30;
Buff_Y[0] = (Y % 10) + 0x30;

This is all good. If you print those three bytes, you will see that they contain the right values.


SBUF = *Buff_Y;

This, however, indicates confusion. *Buff_Y is equivalent to Buff_Y[0]. That is a single char value… If you can only store a single char value into SBUF, then you can’t store the three char values you want to store into it.

If we use logic, we can make this inference: That char value will be '0' if the input you provide is evenly divisible by 10 (that is, when Y % 10 is 0)…

While you’re thinking about how to change this line of code (and the parts of your code that we can’t see), you might also want to think carefully about while (TI == 0);. There ought to be a better solution to whatever problem that is attempting to solve.

solved How to change a char to ASCII form?