0% found this document useful (0 votes)
45 views10 pages

Microcontrollers & Embedded Systems

The document contains 10 sections that provide examples of writing assembly language programs (WAP) for the 8051 microcontroller. The examples include: 1) Sending data from internal memory locations through the serial port, 2) Reading data from a port and saving to external memory, 3) Dividing a byte of data from data ROM and saving to external RAM, 4) Dividing a byte from program ROM and saving to external RAM, 5) Copying a word from ROM to internal RAM, 6) Accessing external memory from a C program, 7) Storing and sending data to a port from external RAM in C, 8) Converting hex to ASCII, and 9-10) Code snippets for hex

Uploaded by

pallavi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views10 pages

Microcontrollers & Embedded Systems

The document contains 10 sections that provide examples of writing assembly language programs (WAP) for the 8051 microcontroller. The examples include: 1) Sending data from internal memory locations through the serial port, 2) Reading data from a port and saving to external memory, 3) Dividing a byte of data from data ROM and saving to external RAM, 4) Dividing a byte from program ROM and saving to external RAM, 5) Copying a word from ROM to internal RAM, 6) Accessing external memory from a C program, 7) Storing and sending data to a port from external RAM in C, 8) Converting hex to ASCII, and 9-10) Code snippets for hex

Uploaded by

pallavi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

MICROCONTROLLERS

& EMBEDDED
SYSTEMS

WAP to configure 8051 in Serial communication Mode 0.


Send the data values stored in locations 700H to 70BH
through serial port to an external device.
700H-70BHInternal ROM
Ragam R_DEEE_RSET

MOV DPTR,#700H
MOV R2,#0AH
MOV SCON,#00H
LOOP1:CLR A
MOVC A,@A+DPTR
MOV SBUF,A
WAIT:JNB TI,WAIT
CLR TI
INC DPTR
DJNZ R2,LOOP1
END

Write a program to read 200 bytes of data from P1 and save


the data in external RAM starting at RAM location 5000H.

Ragam R_DEEE_RSET

MOV DPTR,#5000H
MOV P1,#0FFH
MOV R3,#200
AGAIN: MOV A,P1
MOVX @DPTR,A
INC DPTR
DJNZ R3,AGAIN
END

WAP to access a byte of data which is in data


ROM(0000H), divide it by 2 and save quotient in
external data RAM(8000H)

Ragam R_DEEE_RSET

ORG 0H
MOV DPTR,#0000H
MOVX A,@DPTR
MOV B,#02H
DIV AB
MOV DPTR,#8000H
MOVX @DPTR,A
END
4

WAP to access a byte of data which is in program


ROM(0100H), divide it by 2 and save quotient in
external data RAM(8000H)
Ragam R_DEEE_RSET

ORG 0000H
MOV DPTR,#0100H
CLR A
MOVC A,@A+DPTR To fetch data in Program ROM
MOV B,#02H
DIV AB
MOV DPTR,#8000H
MOVX @DPTR,A To move data to Data RAM
END

A word PPT has been burned in the ROM locations starting


from 0100H onwards.WAP to copy this data into the internal
data RAM locations starting from 60H onwards.

ORG 0100H
TBL:DB PPT
END

Ragam R_DEEE_RSET

MOV DPTR,#0100H or MOV DPTR,#TBL


MOV R2,#03H
MOV R0,#60H
LOOP: CLR A
MOVC A,@A+DPTR
MOV @R0,A
INC DPTR
INC R0
DJNZ R2,LOOP

To access external data space (RAM or ROM) of


the 8051 using C
XBYTE[loc] is used where loc is between the
address 0000H-FFFFH
Found in the header file absacc.h

Ragam R_DEEE_RSET

Write a 8051 C pgm (1) to store ASCII letters A to E in ext.


RAM addresses starting at 0 (2) get the same data from
external RAM and send it to P1 one byte at a time.

void main(void)
{ unsigned char x;
XBYTE[0]=A;
XBYTE[1]=B;
XBYTE[2]=C;
XBYTE[3]=D;
XBYTE[4]=E;

Ragam R_DEEE_RSET

#include<reg51.h>
#include<absacc.h>
for(x=0;x<5;x++)
P1=XBYTE[x];
}

HEX ASCII

To display the data on an LCD or PC screen, Hex


numbers need to be converted to ASCII

Convert 8-bit binary (hex) data to decimal digits, 000


255

Convert the decimal digits to ASCII digits,30H 39H

9
Ragam R_DEEE_RSET

MOV R0,#40H
MOV R1,#50H
LOOP2:MOV A,@R0
ADD A,#30H
MOV @R1,A
INC R1
INC R0
DJNZ R2,LOOP2
END

Ragam R_DEEE_RSET

MOV P1,#0FFH
MOV A,P1
MOV R2,#00H
MOV R0,#40H
LOOP1:MOV B,#0AH
DIV AB
MOV @R0,B
INC R0
INC R2
CJNE A,#0AH,LOOP
LOOP:JNC LOOP1
MOV @R0,A

10

You might also like