Professional Documents
Culture Documents
AVR Programming in C
Data Conversion
DDRB =0xFF; //Port B =O/P
1. ASCII to BCD, BCD to ASCII w&= 0x0F; //Mask upper nibble
µcontrollers have a real time clock (RTC) where w<<=4; // Make upper nibble
time & date are kept even when power is OFF. z&= 0xF0; //Mask lower nibble
The format is usually "Packed BCD". To display bcdbyte=w|z; //(w,z)=(upper,lower)=47
them, we convert into ASCII. PORTB=bcdbyte; //Display pack_BCD
return 0;
}