


I would have had the screwup fairy visit me on that one. Of course, I use 5 digit with a string of 6 char. To store a five character string, you must have six available spaces, or the terminator will overwrite something else. Remember in C, 'strings' are just arrays of bytes, with a '0' terminator (numerical zero, not ASCII '0'). The string storage area, should be _six_ characters long, not the five being shown above. Now each element of bcd_string contains the 10^0 to 10^4 I suspect your looking for a 5 digit non packed(4 digit) bcd I decided to use the way of sprintf to a string and then I convert all character to number. I wrote the following code to use in a display: There is not any CCS function to do this convertion. The bin/dec convertion is made ONLY while outputing a char to console, it is not available for further use. So the number 29 would be encoded as 0010 1001 instead of its binary equivalent 0001 1101 Is a coding system in which each decimal digit from 0 to 9 is represented by a 4-digit binary number.Īlso called packed decimal, this is the representation of a number by using four binary bits The question itself has a conceptual mistake as well pointed by RJ. Location: Buenos Aires, La Reina del Plata This is base 'C', nothing special to CCS. Using sprintf instead, will allow these to be sent to a string. Will output the five ascii text digits to the current com device. Have you got any suggestion to do that with CCS compiler ? In past I wrote an assembler routine for motorola HC11. I need to convert an 16 bit hex number, for example 0xffff, to decimal 5 digit as 6 5 5 3 5. These handle single bytes, but a call to 'make8', will allow a 16bitvalue to be handled as well. The DS1302.c driver in the standard library, also contains such a routine. There have been library routines published here in the past (I have posted some, and have seen others). The 'point' about BCD, is that it uses four bits to represent a single digit.

Is there any function in CCS compiler to do it ?Ī 16bit number, will only correspond to 4BCD characters, not five. I need to convert 16 bit hex number into BCD 5 digit. Please do not post bug Reports on this forum. CCS :: View topic - bcd Conversion of 16bit numberįAQ Forum Help Official CCS Support Search Register Profile Log in to check your private messages Log inĬCS does not monitor this forum on a regular basis.
