Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

mapping external ROM memory in 8051

Status
Not open for further replies.

Elnegm

Member level 1
Joined
Jun 28, 2005
Messages
33
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,524
I want to ensure some knowladge i gained about 8051
first program counter is 15 bit so if pc less than 4096 we read from internal ROM but if pc larger than 4096 so PSEN is asserted high and we read from external ROM , and if in the program we asserted PSEN so we read from external ROM even if address less than 4096
Is that right???
Thanks in advance
 

There is no way you can "assert" PSEN in program ..

If you want to read external program memory starting from address 0000h you have to wire /EA to 0V ..

If /EA is connected to +5V 80C51 will read internal program memory (0000h-0FFFh) and whenever the program counter (PC) contains a number that is larger than 0FFFh it will fetch bytes from external program memory ..

Of course 8051-derivatives have different internal progam memories, for example, AT89S53 has 12k, but all microcontrollers will behave in the same manner: /EA=0 - only external memory, /EA=1 - first internal - then external program memory ..

Regards,
IanP
 

> first program counter is 15 bit
In most '51 derivatives (including the "original" 8051), program counter is 16 bit.

However, the exact number of bits of program counter and it's behaviour when it runs out of the internal code memory range is derivative dependent. There are a lot of derivatives today which have no provisions to run from external code memory.

wek
 

I have been driving myself crazy over a bit of 8051 memory mapped io that I have working on. I have it working in assembly language. I have come up with what to me should be a very simple c program but it does not work. It monitors a 4 button keypad and lights a specific LED for each key pressed. Currently it only lights the first LED before any button press but none afterwards. Here is both sets of code. Can anybody see something I'm missing? Thanks in advance!

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

#define KEYPAD 0XFFF4 //Keypad address in xdata

sbit P1_4 = P1^4;
sbit P1_5 = P1^5;
sbit P1_6 = P1^6;
sbit P1_7 = P1^7;

char c;


//Function prototype
unsigned char input(unsigned int address);

void main (void)
{

c = 0;
while (c < 4)
{


if ( c==0) P1_4 = 0; //When p1_4 = 0 LED is on
else if (c==1) P1_5=0;
else if (c==2) P1_6=0;
else if (c==3) P1_7=0;


while (P3^2);

P1=P1|0XF0;

c = input(KEYPAD);


}
}

/*****************************************************************
Function: input

Description: Reads the value at the specified XDATA address.

Parameters: address - unsigned int. Indicates address to read
from.

Returns: The value read at the specified address.

Side Effects: The interrupt system is temporarily halted.
*****************************************************************/

unsigned char input(unsigned int address)

{
unsigned char data value;
EA=0; // block all interrupts

value=XBYTE[address]; // read in the data

EA=1; // allow interrupts again

return value;
}

/****************************************************************/

In assembly;

Filename OLED.ASM
;This program will flash output LEDs
;The idea here is to first disconnect int0 from the keypad
;by placing a 0 in the IE register at address A8H. Then the
;pin p3.2 ,which the keypad is connected to, is just an ordinary
;I/O pin. When any key is hit p3.2 will go low and we exit the LTX:
;loop. Then move the keypad code, which is at address FFF4H, into
;the accumulator and into R0. Then test, with JNZ instruction, to
;see if the number in accumulator is 0, 1, 2, or 3 and turn on the
;corresponding LED. If ACC is 0, 1, 2, or 3 then start over. If not
;then exit program.
;P1 DATA 90H ;port#1 address
KEY_D EQU 0FFF4H ;keypad port address
;EX0 BIT 0A8H ;interrupt 0 bit address
P3_2 BIT 0B2H ;pin p3.2 on the 80c32
P1_4 BIT 094H ;led O1
P1_5 BIT 095H ;led O2
P1_6 BIT 096H ;led O3
P1_7 BIT 097H ;led O4
;***************************************
ORG 7000H ;start address @7000h
;
CLR EX0 ;disable interrupt 0 so keypad is just
;connected to pin 3.2 , by way of the
;74HC74 , as an ordinary I/O pin
MOV DPTR, #KEY_D ;keypad address
LTX: JB P3_2, $ ;wait for key hit, pin p3.2 goes low
ORL P1, #0F0H ;turn off LEDs
MOVX A, @DPTR ;read key code
MOV R0, A ;save key code
;if acc=0 turns on led O1
JNZ TEST1 ;jump to next test
CLR P1_4 ;turn on led O1
SJMP LTX ;read key code again
;if acc=1 turns on led O2
TEST1: XRL A, #01 ;test if code=1
JNZ TEST2 ;jump to next test
CLR P1_5 ;turn on led O2
SJMP LTX ;read key code again
;if acc=2 turns on led O3
TEST2: MOV A, R0 ;restore key code lost in previous XRL test
XRL A, #02 ;test if code=2
JNZ TEST3 ;jump to next test
CLR P1_6 ;turn on led O3
SJMP LTX ;read key code again
;if acc=3 turns on led O4
TEST3: MOV A, R0 ;restore key code
XRL A, #03 ;test if code=3
JNZ $+6 ;exit
CLR P1_7 ;turn on led O4
SJMP LTX ;read key code again
;exit
SETB EX0 ;reconnect keypad to interrupt 0
RET
END
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top