Делаю так. Только в ASCII преобразование нужно добавить (+0x30) и ноль в конце.
//Convert binary digit to BCD:
//x - input binary digit (32 bits, unsigned)
//buff - output array (10 digits)
void Long2BCD(unsigned long x, char *buff)
{
for(char i = 0; i < 10; i++)
buff[i] = 0; //output buffer clear
for(char i = 0; i < 32; i++) //cycle for input bits count
{
char c = (x >> 31) & 1; //save carry
x = x << 1; //input value shift
for(char p = 0; p < 10; p++) //cycle for digits number
{
char s = buff[p]; //read digit
s = (s << 1) | c; c = 0; //shift with carry
if(s > 9) { s += 0x06; c = 1; } //digit correction
s &= 0x0F; //select nibble
buff[p] = s; //save digit
}
}
}