Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Packed BCD
73H
0111 0011
Unpacked BCD
07H 03H
0000 0111 0000 0011
ASCII
37H 33 H
0011 0111 0011 0011
unsigned short myBcd2Dec(unsigned short bcd){
return ((bcd >> 4)*10+(bcd & 0x0F));
}
Can any one please explain following codes step by step that I can not understand
unsigned short myBcd2Dec(unsigned short bcd){
return ((bcd >> 4)*10+(bcd & 0x0F));
}
unsigned short BCD1 = 0x73;
unsigned short Result;
Result = myBcd2Dec(BCD1); // Result = 0x49 or 73
BCD1 = 0111 0011
((bcd >> 4)*10 + (bcd & 0x0F))
bcd & 0x0F
(bcd >> 4)*10
((bcd >> 4)*10 [COLOR="#FF0000"]+[/COLOR] (bcd & 0x0F))
unsigned char BCD2UpperCh(unsigned char bcd)
{
return ((bcd >> 4) + '0');
}
unsigned char BCD2LowerCh(unsigned char bcd)
{
return ((bcd & 0x0F) + '0');
}
second=I2CRead();
bcdToascii(second);
unsigned char bcdToascii(unsigned char bcd){
return ((bcd>>4)+'0');
unsigned char time[9];
unsigned char sec;
unsigned char min;
unsigned char hour;
...
unsigned char getSeconds();
unsigned char getMinutes();
unsigned char getHours();
...
...
...
sec = getSeconds();
min = getMinutes();
hour = getHours();
....
....
time[0] = BCD2UpperCh(hour);
time[1] = BCD2LowerCh(hour);
time[2] = ':';
time[3] = BCD2UpperCh(min);
time[4] = BCD2LowerCh(min);
time[5] = ':';
time[6] = BCD2UpperCh(sec);
time[7] = BCD2LowerCh(sec);
time[8] = '\0';
putStringLCD(time);
void bcdToascii(unsigned char value){
tmp = value;
tmp = tmp & 0xf0;
tmp = tmp >> 4;
tmp = tmp | 0x30;
[COLOR="#FF0000"]lcddata(tmp);[/COLOR]
tmp = value;
tmp = tmp & 0x0f;
tmp = tmp | 0x30;
[COLOR="#FF0000"]lcddata(tmp);[/COLOR]