0% found this document useful (0 votes)
160 views6 pages

Keil Tutorial v2

The document discusses interfacing the 8051 microcontroller with external memory. It covers interfacing with external ROM in Section 14.1, interfacing with external data memory in Section 14.2, and accessing external data memory in 8051 C code in Section 14.3. Some key topics include using the ALE pin to separate address and data when accessing external ROM, using RD and WR pins to access external data memory, and using the XBYTE keyword in 8051 C code to access external memory locations. Sample code is provided to demonstrate transferring data between on-chip and external memory locations.

Uploaded by

Muhammad Jamil
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)
160 views6 pages

Keil Tutorial v2

The document discusses interfacing the 8051 microcontroller with external memory. It covers interfacing with external ROM in Section 14.1, interfacing with external data memory in Section 14.2, and accessing external data memory in 8051 C code in Section 14.3. Some key topics include using the ALE pin to separate address and data when accessing external ROM, using RD and WR pins to access external data memory, and using the XBYTE keyword in 8051 C code to access external memory locations. Sample code is provided to demonstrate transferring data between on-chip and external memory locations.

Uploaded by

Muhammad Jamil
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/ 6

CHAPTER 14: 8051 INTERFACING TO EXTERNAL MEMORY

Section 14.1: 8031/51 Interfacing with External ROM

1. 3FFFh
2. 0000h
3. 17, 16; 3; P3.6 and P3.7
4. 64
5. True
6. True
7. (c)
8. (a), (b), (d)
9. Port 0
10. Port 2
11. Port 0
12. ALE = 0 is for the address, while ALE = 1 is for the data.
13. 17, 6; PSEN is pin 29 and does not belong to any port.
14. (c)
15. 0000h, external ROM
16. The 8051 starts to access the on-chip ROM at address 0000 and goes on to the last
location of the on-chip ROM which is 3FFFh and then goes to the external ROM for
more code if it is not stopped.
17. True
18. PSEN is used for all external program fetches.

Section 14.2: 8051 Data Memory Space

19. RD and WR pins are used to access external data.


20. 64
21. (a)
22. All are active low .
23. True
24. MOVC is used to get data from code space, while MOVX is used to get data in the data
space of the microcontroller.
25.
RAMDATA EQU 60h
ROMDATA EQU 2000h
COUNT EQU 20

MOV DPTR, #ROMDATA


MOV R2, #COUNT
MOV R1, #RAMDATA
AGAIN: MOVX A, @DPTR
MOV @R1, A
INC DPTR
INC R1
DJNZ R2, AGAIN

76
26. RAMDATA EQU 40h
ERAMDATA EQU 6000h
COUNT EQU 30

MOV DPTR, #ERAMDATA


MOV R2, #COUNT
MOV R1, #RAMDATA
AGAIN: MOV A, @R1
MOVX @DPTR, A
INC DPTR
INC R1
DJNZ R2, AGAIN

27. ACALL ROM_IN


ACALL RAM_OUT
SJMP $
ROM_IN:
RAMDATA EQU 60h
ROMDATA EQU 3000h
COUNT EQU 50

MOV DPTR, #ROMDATA


MOV R2, #COUNT
MOV R1, #RAMDATA
AGAIN: MOVX A, @DPTR
MOV @R1, A
INC DPTR
INC R1
DJNZ R2, AGAIN
RET
;-----------------
RAM_OUT:
RAMDATA EQU 60h
ERAMDATA EQU 8000h
COUNT EQU 50

MOV DPTR, #ERAMDATA


MOV R2, #COUNT
MOV R1, #RAMDATA
AGA: MOV A, @R1
MOVX @DPTR, A
INC DPTR
INC R1
DJNZ R2, AGA
RET

Instructor’s Manual for “The 8051 Microcontroller: A System Approach” 77


28.
RAMDATA EQU 60h
ROMDATA EQU 3000h
COUNT EQU 50
ACALL ROM_IN
ACALL RAM_OUT
SJMP $
ROM_IN:

MOV DPTR, #ROMDATA


MOV R2, #COUNT
MOV R1, #RAMDATA
AGAIN: MOVX A, @DPTR
MOV @R1, A
INC DPTR
INC R1
DJNZ R2, AGAIN
RET
;-----------------
RAM_OUT:
; Continued on next page

78
MOV A, 0C4h
SETB ACC.0
MOV 0C4h, A
MOV DPTR, #0000h
MOV R1, #RAMDATA
MOV R2, #COUNT
NEXT: MOV A, @R1
MOVX @DPTR, A
INC R1
INC DPTR
DJNZ R2, NEXT
RET

29.
MOV A, 0C4h
SETB ACC.0
MOV 0C4h, A
MOV DPTR, #0200h
MOV R1, #50
NEXT: MOV A,@DPTR
MOV P1, A
INC DPTR
ACALL DELAY
DJNZ R1, NEXT
SJMP $
DELAY:
...

30. C4h is the address. 80h is the content upon reset.


31. DS89C4x0 family.
32. blocked
33. 0000h – FFFFh
34. 0400h – FFFFh

Section 14.3: Accessing External Data Memory in 8051 C

35. #include <reg51.h>


#include <absacc.h>

void main(void)
{
unsigned char cnt;
unsigned char x;
unsigned char myarray[20];
for(cnt=0;cnt<20;cnt++)
{
x=XBYTE[0x2000+cnt];
myarray[cnt]=x;
}
}

Instructor’s Manual for “The 8051 Microcontroller: A System Approach” 79


36. #include <reg51.h>
#include <absacc.h>

void main(void)
{
unsigned char cnt;
unsigned char x;
unsigned char myarray[30]="012345678901234567890123456789";
for(cnt=0;cnt<30;cnt++)
{
x = myarray[cnt];
XBYTE[0x6000+cnt] = x;
}
}

37. #include <reg51.h>


#include <absacc.h>

void main(void)
{
unsigned char cnt;
unsigned char x;
for(cnt=0;cnt<50;cnt++)
{
x=XBYTE[0x3000+cnt];
XBYTE[0x8000+cnt]=x;
}
}

38. #include <reg51.h>


#include <absacc.h>
sfr PMRREG = 0xC4;
void main(void)
{
unsigned char cnt;
unsigned char x;
PMRREG = PMRREG | 0x01;
for(cnt=0;cnt<50;cnt++)
{
x=XBYTE[0x3000+cnt];
XBYTE[0x0000+cnt]=x;
}
}

80
39. #include <reg51.h>
#include <absacc.h>
sfr PMRREG = 0xC4;

void MSDelay(unsigned int itime);

void main(void)
{
unsigned char cnt;
unsigned char x;
PMRREG = PMRREG | 0x01;
for(cnt=0;cnt<100;cnt++)
{
x=XBYTE[0x200+cnt];
P1=x;
MSDelay(1000);
}
}

void MSDelay(unsigned int itime)


{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}

Instructor’s Manual for “The 8051 Microcontroller: A System Approach” 81

You might also like