Handling External RAM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Handling External RAM

2,245 Views
NZ_Design
Contributor I
How well does CW handle external RAM on the MC9S12DP256 processor.
 
This processor only has a PPage registor on dpage therefor code and ram are handled by the same register. I have used the ICC compiler for my code in the past and it didnt handle external RAM at all. I therefore had to do special code to deal with it.
 
#define pLocation 0x4003
#define newpage 0x10
 
coldpage = PORTK;
PORTK = newpage;
asm("nop"); // as PORTK requires an extra clock cycle to change correctly
*(int*)pLocation := 34;
PORTK = cOldPage;
in the code worrier I have decleared the RAM as such
   PAGE_10 = NO_INIT    0x104000 TO 0x107FFF;
   PAGE_11 = READ_WRITE 0x114000 TO 0x117FFF;
   PAGE_12 = READ_WRITE 0x124000 TO 0x127FFF;
   PAGE_13 = READ_WRITE 0x134000 TO 0x137FFF;
   PAGE_14 = READ_WRITE 0x144000 TO 0x147FFF;
   BATTERY_RAM                  INTO PAGE_11,PAGE_12,PAGE_13,PAGE_14,PAGE_15,PAGE_16,PAGE_17,
                                     PAGE_18,PAGE_19,PAGE_1A,PAGE_1B,PAGE_1C,PAGE_1D,PAGE_1E,PAGE_1F;
   PROGRAM_RAM                  INTO PAGE_10;
 
 
 
#pragma DATA_SEG BATTERY_RAM 
 uchar pLocation;
#pragma DATA_SEG DEFAULT
 pLocation = 34;
 
I am ok while the system is runnung but as soon as I turn the unit off the value is lost. The external memory is battery backed and it is working. As I can load my old Image craft code and it is stored.
 
Do I need to modify the datapage.c file so as when dealling with code it works on PORTK rather than the ppage register.
 
 
Labels (1)
Tags (1)
0 Kudos
4 Replies

460 Views
CrasyCat
Specialist III
Hello
 
  CodeWarrior for HCS12DP256 is accessing paged data or constant through PPAGE only.
  It does not use PORTK at all.
 
  If you wish to use PORTK to access external RAM, you have to write low level functions (or macros), which are accessing
  paged variable through PORTK and access the variables through the function.
 
CrasyCat
0 Kudos

460 Views
NZ_Design
Contributor I
How do I do a macro then so as I dont have to declear my variables as fixed addresses etc. As if I have to do that then it is a wast of time me changing the code over to CW.
0 Kudos

460 Views
CompilerGuru
NXP Employee
NXP Employee
Some things here are not clear to me.
If EMK is set, then PORTK is not in the memory map.
So what effect should "PORTK = newpage;" have in this case? Should this be "PPAGE= newpage;"?
Also is it possible to use the 0x4000..0x7FFF area for memory expansion? Reading the description in S12MMCV4.pdf, "4.3.2 Extended Address (XAB19:14) and ECS Signal Functionality" chapter
system is addressing within the physical Program Page
Window address space ($8000–$BFFF) and is in an expanded mode. When addressing anywhere else
within the physical address space (outside of the paging space), the XAB19:14 signals will be assigned a
constant value based upon the physical address space selected.

So this sounds to me as if you would get a fixed "$3E" page whenever you do an access in the 0x4000..0x7FFF window (or as in your prm, to "0x104000 TO 0x107FFF"), should this be "0x108000 TO 0x10BFFF" in the prm instead? Anyway, this is not my area, I really might be just totally wrong.

Can you show the code you expect to get the compiler generate when it does access "pLocation"?

Also, when accessing paged data, you have to tell the compiler which page register to use.
To use PPAGE:
#pragma DATA_SEG __PPAGE_SEG BATTERY_RAM.
0 Kudos

460 Views
NZ_Design
Contributor I
You are sort of right but PPage is emulated on PORTK when the EMK bit is set in the MODE register.
 
Therefore what I are doing in thery should work. but PORTK(PPAGE) never gets a 0x10 (my ram address)set on it. Yet data is put into the memory and stored there while the system is running.
 
 
0 Kudos