Pumpkin, Inc.

Pumpkin User Forums

How to access external RAM

For issues specific to the 8051 family, including compilers (e.g. Keil C51) and IDEs (e.g. uVision2).

How to access external RAM

Postby sncuser » Sun Jul 06, 2014 7:26 pm

Is there an example somewhere of how to access the 128KB external static RAM on the B1 PPM? Maybe one I don't have for whatever reason?
sncuser
 
Posts: 22
Joined: Thu Feb 13, 2014 2:49 pm

Re: How to access external RAM

Postby sncuser » Tue Jul 22, 2014 2:22 pm

I would still like some guidance on this.

Thanks,
sncuser
 
Posts: 22
Joined: Thu Feb 13, 2014 2:49 pm

Re: How to access external RAM

Postby Andrew » Wed Jul 23, 2014 6:47 am

Which group / CubeSat are you with?
Andrew
Site Admin
 
Posts: 68
Joined: Mon Nov 30, 2009 6:43 pm

Re: How to access external RAM

Postby Andrew » Fri Jul 25, 2014 12:52 pm

OK, so I know who you are now ... :-)

The external RAM on PPM B1 was requested by a customer when PPM B1 was developed ... we are not at liberty to release their 8051 code, which utilizes the external RAM. However, I can give you some pointers:

1) The RAM is treated as off-chip RAM.

2) You must control HIADR_PORT (to set the HIADDR port to the PDATA page) and EMIOCN (to make sure it's set to the PDATA page), on their respective (SFR) pages.

3) The hi address port is P6.

4) -CS is P5.6, BANK_SEL is P5.7, and the control port is P5.

The hardware connections, you can see via the schematics, which you have access to.

Once you've configured the C8051 for this external memory -- and told the KC51 compiler where that memory is -- then you can use it as off-chip memory. I don't recall if it's pdata or xdata ...
Andrew
Site Admin
 
Posts: 68
Joined: Mon Nov 30, 2009 6:43 pm

Re: How to access external RAM

Postby sncuser » Fri Jul 25, 2014 6:08 pm

Thanks. I'm surprised that there is a product advertised with 128 KB of external RAM with no instructions on how to use it, but I'm also not very familiar with this market. I had no knowledge of it at all prior to this particular project.

Can I ask what MEMBUS and MEMBANK are used for on this product? I had interpreted the data sheet to indicate that these were used for this purpose.
sncuser
 
Posts: 22
Joined: Thu Feb 13, 2014 2:49 pm

Re: How to access external RAM

Postby sncuser » Fri Jul 25, 2014 8:56 pm

Oh, I see. MEMBUS and MEMBANK are P5.6 and P5.7.

Thanks for the info.
sncuser
 
Posts: 22
Joined: Thu Feb 13, 2014 2:49 pm

Re: How to access external RAM

Postby Andrew » Tue Jul 29, 2014 8:17 am

The gymnastics that a poor old 8051 has to go through to access large amounts of memory are non-trivial .... that said, Keil has done a great job on that compiler, effectively hiding the banking, etc. as long as the hardware is in place (as it is on PPM B1) and the appropriate software hooks are provided by the end-user.
Andrew
Site Admin
 
Posts: 68
Joined: Mon Nov 30, 2009 6:43 pm

Re: How to access external RAM

Postby sncuser » Thu Apr 16, 2015 8:43 pm

Getting back to this after many months, it's now become urgent. I must get this worked out quickly, but it seems as if I'm missing something.

You said earlier: "You must control HIADR_PORT (to set the HIADDR port to the PDATA page) and EMIOCN (to make sure it's set to the PDATA page), on their respective (SFR) pages." and "The hi address port is P6." I don't know what this means, and maybe this is the piece that I'm missing. What is the PDATA page, and why does P6 and EMI0CN need to point to it?

Also, " -CS is P5.6, BANK_SEL is P5.7, and the control port is P5." I'm doing this. More details in just a second.

My setup is currently like this:

I'm using the on-chip XRAM, with an off-chip Xdata area defined from 0x2000 and size 0xDFFF, with the 'far' memory type support and saving of the address extension SFR in interrupts. I'm using the extended linker and have user classes set up like this: XDATA (X:0x0-X:0x1FFF, X:0x02000-X:0xFFFF), CODE (C:0x0-C:0xFFFF), HDATA (X:0x002000-X:0x00FFFF, X:0x012000-X:0x01FFFF).

In L51_BANK.A51, I have B_NBANKS set to 2 (not sure if this is necessary for using the external RAM), B_MODE set to 0, and B_VAR_BANKING set to 1. In the code for B_MODE==0, I have the address of the P5 port. In my code, I have P5.6=0 and P5.7 slternating between 0 and 1 to ret to switch the banks.

In STARTUP.A51, I have XDATASTART = 0H and XDATALEN = 0FFFFH.

I've also tried variations on all of this, and a fairly consistent result is that I seem to be able to use the internal memory up to 0x2000, and memory from 0x8000-0xFFFF. But I can't seem to switch banks. I also can't seem to use the memory between 0x2000 and 0x8000, by using raw pointers, except that if I create some sizeable arrays that push my data up above 0x2000, then I can manipulate those areas with my pointers, except if I make my array larger than 8K so that the data gets pushed into the 0x4000 range, I still can't manipulate bytes in the 0x4000 range. They are alsways 0xFF.

Thank you very much for any help you can provide.
sncuser
 
Posts: 22
Joined: Thu Feb 13, 2014 2:49 pm

Re: How to access external RAM

Postby sncuser » Thu Apr 16, 2015 11:04 pm

Also, EMI0CF = 0x3B
sncuser
 
Posts: 22
Joined: Thu Feb 13, 2014 2:49 pm

Re: How to access external RAM

Postby sncuser » Fri Apr 17, 2015 2:26 pm

Got it working! Turns out I was not successfully controlling the CS, so the memory was never getting enabled.
sncuser
 
Posts: 22
Joined: Thu Feb 13, 2014 2:49 pm


Return to 8051 family

Who is online

Users browsing this forum: No registered users and 2 guests

cron