AnsweredAssumed Answered

converting BCD

Question asked by Md Mubdiul Hasan on Sep 26, 2016
Latest reply on Nov 7, 2016 by Md Mubdiul Hasan

Dear All,

I need to make BCD  4 digit in 7-segment display.

My spi recieved data is 14 bit, take a look this sample code in another MCU.

void toBCD(int16 val,int8 * buff) { 
   //converts 16bit value, to five BCD digits. Tries to do it fairly 
   //efficiently, both in size, and speed. 
   int1 temp_bit; 
   int8 nibctr; 
   do { 
      if ((buff[0] & 0xF)>=5) buff[0]+=3; 
      if ((buff[0] & 0xF0)>=0x50) buff[0]+=0X30; 
      if ((buff[1] & 0xF)>=5) buff[1]+=3; 
      if ((buff[1] & 0xF0)>=0x50) buff[1]+=0X30; 
      if ((buff[2] & 0xF)>=5) buff[2]+=3; 
   } while (val!=0); 

void main() { 
   int16 val; 
   //three bytes for packed BCD result 
   int8 buff[3]; 
   //At this point, the three bytes will contain: 
   // 45 
   // 23 
   // 01 
   while (true); 


1. How can I implement this idea in RTC application?

2. Is it possible to apply this link ..

Kindly help me.

Refference code is required.