Example 7-27 Write an AVR C program to convert ASCII digits of 4′ and ‘7’ to packed BCD and dis- play them on PORTB. Solution: include <avr/ io.h> //standard AVR header int main (void) unsigned char bcdbyte; unsigned char w 4 unsigned char z 7 DDRB 0xFF: WW &0x0F //make Port B an output //mask 3 //shift left to make upper BCD digit //mask 3 //combine to make packed BCD bcdbyte wI zi
OR
OR