0% found this document useful (0 votes)
39 views

Lab 7F BCD and Ascii Conversion in C: Lab Manual For "The 8051 Microcontroller "

This document outlines three activities for a lab on BCD and ASCII conversion in C using an 8051 microcontroller. The activities include: 1) Writing a program to get a packed BCD value from DIP switches and display the ASCII equivalent on LEDs with a 4-second delay. 2) Modifying the program to sound a buzzer if the input is not a valid packed BCD value. 3) Writing a program to convert two ASCII numbers to a packed BCD value and display the result on LEDs. The document also includes a worksheet with questions related to bitwise operations on a single byte.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Lab 7F BCD and Ascii Conversion in C: Lab Manual For "The 8051 Microcontroller "

This document outlines three activities for a lab on BCD and ASCII conversion in C using an 8051 microcontroller. The activities include: 1) Writing a program to get a packed BCD value from DIP switches and display the ASCII equivalent on LEDs with a 4-second delay. 2) Modifying the program to sound a buzzer if the input is not a valid packed BCD value. 3) Writing a program to convert two ASCII numbers to a packed BCD value and display the result on LEDs. The document also includes a worksheet with questions related to bitwise operations on a single byte.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

LAB 7F

BCD AND ASCII CONVERSION IN C


OBJECTIVE:
BCD and ASCII Conversion using C program.
REFERENCE:
Mazidi and McKinlay, The 8051 Microcontroller , Chapter 7
MATERIALS:
MDE 8051 Trainer
8051 Keil C Compiler

ACTIVITY 1
Write a program to get a byte of packed BCD from DIP switches
connected to P1 and display the result on LEDs of P2 with 4-second delay in
between each ASCII showing. Run the program to verify it works.
ACTIVITY 2
Modify the program in Activity 1 to sound the buzzer if the input value
on DIP switches are not packed BCD ($00-$99). That means, it will convert
only the BCD data and displays ASCII numbers on LEDs and if the input data
is not packed BCD (e.g. 10011111 binary) it will sound the buzzer and LEDs
will have all zeros.
ACTIVITY 3
Write a program to convert two ASCII numbers to a packed BCD and
display the BCD result on LEDs of PORTB. Run the program to verify it works.
unsigned char ascii_1= 0x39;
unsigned char ascii_2=0x37;

Lab Manual for The 8051 Microcontroller

LAB 7F
WORKSHEET
Name:

Date:

Class:

1. Find the value z after the following code.


unsigned char z=0x89;
z=z>>3;
z=

in hex

2. Find the value z after the following code.


unsigned char z=0x89;
z=z<<3;
z=

in hex

3. Show the code for swapping the nibbles of a single byte in C.

4. Find the value z after the following code.


unsigned char z=0x89;
z=z^0xFF;
z=

in hex

5. Find the value z after the following code.


unsigned char z=0x89;
z=z&0x0F;
z=

in hex

Lab Manual for The 8051 Microcontroller .

You might also like