visva
Member level 3
i tried, the following programs for display time in LCD which had read from timer DS1307(by using i2c protocol) and i am micro controller 89c52.The first program can convert and display the correct value. But the second program cannot give the correct answer. so please help me what is going on in these programs.
HTML:
[B]Tell me the error and logic of these two programs.[/B]
Code:
void ascii_display(unsigned char time)
{
unsigned char buf=0;
buf=((time >> 4)+'0');
display1(buf);
buf=((time & 0x0F)+'0');
display1(buf);
}
Code:
void ascii_display(unsigned char time)
{
unsigned char buf=0;
buf=time&0xF0;
buf=(buf>>4)|0x30;
display1(buf);
buf=time&0x0F;
buf=buf|30;
display1(buf);
}