Z
zion_zii
Im working on an embedded project and i have to obtain individual
digits from a byte thats the output of a device. Im trying to output
this info to an LCD and need to convert it to ASCII first. I have the
following which only works for single digits but not double digits.
(Data from chip is stored in current[] array and needs to be converted
and stored in array hours[]).
hours[0] = 0x30 | ((current[2] & 0x70) >> 4); //obtain the tens minute
digit
//current[2] stores the byte i want to convert,
hours[1] = 0x30 | (current[2] & 0x0F) //obtain the ones minute digit.
;
This only works if i have single digit output but i a value like 36
minutes was read from the device, the output goes crazy. I appreciate
any suggestions/ideas.
zion.
digits from a byte thats the output of a device. Im trying to output
this info to an LCD and need to convert it to ASCII first. I have the
following which only works for single digits but not double digits.
(Data from chip is stored in current[] array and needs to be converted
and stored in array hours[]).
hours[0] = 0x30 | ((current[2] & 0x70) >> 4); //obtain the tens minute
digit
//current[2] stores the byte i want to convert,
hours[1] = 0x30 | (current[2] & 0x0F) //obtain the ones minute digit.
;
This only works if i have single digit output but i a value like 36
minutes was read from the device, the output goes crazy. I appreciate
any suggestions/ideas.
zion.