Week4Day2 (Mod)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Experiment # 2, Week 4, Day 2:

Date: Programming Microcontroller for controlling and interfacing peripheral


hardware Use AT89S52 (8052), write code and burn its hex file into Flash Memory of 8052/8051,
display decimal number 0 to 9 and PHY312, Advance electronics and Instrumentation with 16x2 LCD

Student ID: Name: Section:

Aim of Experiment: To write code and burn its hex file into Flash Memory of
8052/8051 and display some text.

Components Used: Keil uvision 5, Proteus Professional 8, AT89C51


Microcontroller, Resistors, etc.

Marks Viva Experiment Group discussion

Full Marks 15 75 10

Obtained Marks

Group 1
Member
s 2
Instructor’s Signature

Experimental #2: Week 4: Day 2


Use AT89S52 (8052), write code and burn its hex file into Flash Memory of 8052/8051, display
decimal number 0 to 9 and PHY312, Advance electronics and Instrumentation

Fig.1
Write your code and steps followed for burning the program
LCD Display using 8052 Microcontroller

Circuit Verified Result verified Photograph of circuit


attached
Experimental #2: Week 4: Day 2
Use AT89S52 (8052), write code and burn its hex file into Flash Memory of 8052/8051, display
decimal number 0 to 9 and PHY312, Advance electronics and Instrumentation

Write your code and steps followed for burning the program

CODE:

#include<reg51.h>
#include<string.h>
sbit rs = P1^0;
sbit rw = P1^1;
sbit en = P1^2;

void lcdcmd(unsigned char);


void lcddat(unsigned char);
void delay();

void main() {
P2 = 0x00; // declaration for output, d0-d7
while(1) {
lcdcmd(0x38); //declaration for 5X7 matrix crystal
delay();
lcdcmd(0x01); //clear screen
delay();
lcdcmd(0x10); //cursor blinking
delay();
lcdcmd(0x0c); //display on
delay();
lcddat(' ');
delay();
lcddat('P');
delay();
lcddat('H');
delay();
lcddat('Y');
delay();
lcddat('3');
delay();
lcddat('1');
delay();
lcddat('2');
delay();
lcddat(',');
delay();
lcddat(' ');
delay();
lcddat('A');
delay();
lcddat('d');
delay();
lcddat('v');
delay();
lcddat('a');
delay();
lcddat('n');
delay();
lcddat('c');
delay();
lcddat('e');
delay();
lcdcmd(0xc0);
delay();
lcddat(' ');
delay();
lcddat('e');
delay();
lcddat('l');
delay();
lcddat('e');
delay();
lcddat('c');
delay();
lcddat('t');
delay();
lcddat('r');
delay();
lcddat('o');
delay();
lcddat('n');
delay();
lcddat('i');
delay();
lcddat('c');
delay();
lcddat('s');
delay();
lcddat(' ');
delay();
lcddat('a');
delay();
lcddat('n');
delay();
lcddat('d');
delay();
lcdcmd(0x01);
delay();
lcddat(' ');
delay();
lcddat('I');
delay();
lcddat('n');
delay();
lcddat('s');
delay();
lcddat('t');
delay();
lcddat('r');
delay();
lcddat('u');
delay();
lcddat('m');
delay();
lcddat('e');
delay();
lcddat('n');
delay();
lcddat('t');
delay();
lcddat('a');
delay();
lcddat('t');
delay();
lcddat('i');
delay();
lcddat('o');
delay();
lcddat('n');
delay();
}

void lcdcmd(unsigned char val) {


P2 = val;
rs=0;
rw=0;
en=1;
delay();
en=0;
}

void lcddat(unsigned char val) {


P2 = val;
rs=1;
rw=0;
en=1;
delay();
en=0;
}

void delay() {
unsigned int i;
for(i=0; i<10000; i++);
}

Steps followed for burning the program:

1. Write the program in Keil uvision 5 software.


2. Build file from the toolbar using Project>>Build Target.
3. Locate the hex file created by the software, note down the PATH to hex file.
4. Next, double click on the microcontroller. A menu will appear.
5. On the “Program File” box of the menu, enter PATH to the hex file.
6. The hex file is now loaded into the microcontroller.
Circuit Verified Result verified Photograph of circuit
attached

You might also like