
RAM SECTION 5
Page 5-1
RAM SECTION 5
This section discusses accessing RAM and battery
backup.
ACCESSING RAM
RAM is accessed using MOVX type instructions. The
I/O control bit (C PU port P4.0) m ust be high. This bit
is high on power up or reset.
The 8051 series of C PU' s access RA M 64K bytes at a
time. Additional RAM is accessed using a bank
selection scheme. Bank selection in the RPC -220 is
done by writing to an I/O addr ess.
Demonstration program MEM220.C accesses all RAM
segments. Byte and word wide accesses are through
functions speek, spoke, speekw, and spokew.
On power up or reset, RAM segment is set to 0. To
change the RAM segment, do an I/O write to addr ess
0xcYzz
Where:
0xc is the constant part of the address
Y determines the segm ent selected ac cording to
the formula below.
zz is don't care data.
Simply writing to this addr ess sets the segm ent. No data
is involved. Use the following formula to calculate the
address based on the segment desired:
address = 0xc000 + segment * 0x800
The best w ay is in assembly language. T his is shown in
the speek and spoke type routines in MEM220. C under
the ME M220 director y. E ssentially, DPH is loaded with
the address after shifting (multiplying) the segment.
You can use either compiler supplied peek and poke
functions or a pointer to access RAM in segment 0. Use
caution when using these functions to access other
segments. Normally, C stores variables in segment 0.
If you have code like:
CLR P4.0 // set I/O mode
poke(addr1,value1); // set segment
SETB P4.0 // Back to RAM mode
poke(addr2,value2); // Save memory
All of the variables, unless they are register, are bogus
since they were obtained from the wrong segment in
RAM.
WARNING:
Turn off interrupts befor e accessing R AM in
segments 1-7 unless you make your handlers switch
to segment 0. You can use seriously wrong
variables if the progr am assum es they are in
segment 0 and you are working another segment 1.
WARNING:
When you are logging data and are in the
development mode, you can easily modify the code
in segment 0. Code starts at 0x8000. Start logging
data in segment 1.
BATTERY BACKUP
The RPC-220 comes in two versions with battery backed
RAM. Battery backup is controlled by the RTC chip U8.
The supplied battery can expect to back up RAM and
keep the clock going for about 4-6 years with a 128K
RAM, the unit completely off, and sitting at 25°C.
Battery life degrades quickly, about 50%, at 50°C. You
can extend battery back up life by installing your own.
See SECTION 7, EXTERNAL BATTERY, for more
information.
RAM SIZE JUMPER
Jumper W1 configures RAM U4 for 128K or 512K. It is
preset at the factory.
APPLICATION PROGRAMS
The following programs are in the MEM 220 directory.
File name Description
MEM220.C Extended memory access routines.
MEMTST22.C A slow, but extensive m emor y test.
All 512K RAM checked. Prim arily to
check for overlapping memory
segments.
Komentarze do niniejszej Instrukcji