| Author |
Message |
|
|
Posted: Jul 11, 2012 - 07:23 PM |
|

Joined: Mar 07, 2012
Posts: 16
Location: Ukraine
|
|
Hello.
I'm developing device based on ATxmega128A1 microcontroller with 512Kbytes external RAM. And when I began programming I stuck with some strange EBI behavior.
I used 512Kb ( 512K x 8 ) SRAM IC connected via 3 port EBI with multiplexing address bytes 0 and 1.
Exact SRAM connection schematics can be found in attachment.
First of all I tried the next code:
(EBI initialization)
Code:
EBI.CS3.CTRLA = EBI_CS_ASIZE_512KB_gc|EBI_CS_MODE_SRAM_gc;
EBI.CS3.CTRLB = EBI_CS_SRWS_1CLK_gc;
EBI.CS3.BASEADDR = 0x40;
EBI.CTRL = EBI_SRMODE_ALE1_gc|EBI_IFMODE_3PORT_gc;
512Kb RAM size, starts at 0x4000 address (internal SRAM: 0x2000 - 0x3FFF). But it's doesn't work. EBI simply do not generate any signals when I try to access 0x4000 address and above.
After a lot attempts, I've found that the next code is working:
Code:
EBI.CS3.CTRLA = EBI_CS_ASIZE_16M_gc|EBI_CS_MODE_SRAM_gc;
EBI.CS3.CTRLB = EBI_CS_SRWS_1CLK_gc;
EBI.CS3.BASEADDR = 0;
EBI.CTRL = EBI_SRMODE_ALE1_gc|EBI_IFMODE_3PORT_gc;
I tried fill whole 524 288 bytes using a random array received via USB and then read it. All works fine.
But a little later I found a some strange thing - A14 line (14th address bit) is '1' when I tried to access 0x4000 address and above. But if I access 0x3FFF and below - address lines becomes zero. Actually, it works like A14 line is simply inverted and it is not affects access to the entire RAM, including 0x83FFF address.
It seems that EBI transparently outputs address without subtraction 0x4000 offset (what's actually is logical, due to zero BASEADDR).
However, I cannot continue until I do not understand all the details. That's why I asking:
1. How should I initialize EBI in this application?
2. How exactly registers BASEADDR and ASIZE (in CSn.CTRLA) works? (and how they should be configured)
3. In general - what am I doing wrong?
Dear AVR Freaks, please, help me to understand this issue.
Thanks.
UPD.: High resolution image: http://s40.radikal.ru/i087/1207/e6/0e73ec2ba95b.png |
|
|
| |
|
|
|
|
|
Posted: Jul 11, 2012 - 09:30 PM |
|


Joined: Apr 29, 2011
Posts: 199
Location: Portland, OR, US
|
|
| I've used the EBI with SDRAM, not SRAM. I found the ASF driver and example code very useful. The attached files are from ASF 3.2.1. There is also an "ebi_sram_example.c," but there appears to be a limit of three attachments. |
_________________ Gamu The Killer Narwhal
Portland, OR, US
_________________
Atmel Studio 6.1beta on Windows 8
XMEGA-A1/XMEGA-A3BU
AVR Dragon (Ver. 2)
JTAGICE mkII
|
| |
|
|
|
|
|
Posted: Jul 11, 2012 - 10:40 PM |
|

Joined: Mar 07, 2012
Posts: 16
Location: Ukraine
|
|
Yep, I know about ASF. But I want to understand what exactly happens in real hardware
Thanks. |
|
|
| |
|
|
|
|
|
Posted: Jul 14, 2012 - 07:08 PM |
|


Joined: Apr 29, 2011
Posts: 199
Location: Portland, OR, US
|
|
You can't position the entire external SRAM immediately after the internal RAM (0x004000 - 0x083FFF). The SRAM base address must be a multiple of the SRAM size. For a 512KB SRAM this means 0x000000, 0x080000, 0x100000, etc...
If you want the external SRAM to appear in the address space immediately after the internal SRAM, set EBI.CS3.BASEADDR = 0 and say goodbye to the first 16KB of the SRAM. If you need all 512KB, set EBI.CS3.BASEADDR = 0x0800 and the entire SRAM will sit at 0x080000 - 0x0FFFFF in the address space. |
_________________ Gamu The Killer Narwhal
Portland, OR, US
_________________
Atmel Studio 6.1beta on Windows 8
XMEGA-A1/XMEGA-A3BU
AVR Dragon (Ver. 2)
JTAGICE mkII
|
| |
|
|
|
|
|
Posted: Jul 15, 2012 - 08:17 PM |
|

Joined: Mar 07, 2012
Posts: 16
Location: Ukraine
|
|
|
GTKNarwhal wrote:
You can't position the entire external SRAM immediately after the internal RAM (0x004000 - 0x083FFF). The SRAM base address must be a multiple of the SRAM size. For a 512KB SRAM this means 0x000000, 0x080000, 0x100000, etc...
If you want the external SRAM to appear in the address space immediately after the internal SRAM, set EBI.CS3.BASEADDR = 0 and say goodbye to the first 16KB of the SRAM. If you need all 512KB, set EBI.CS3.BASEADDR = 0x0800 and the entire SRAM will sit at 0x080000 - 0x0FFFFF in the address space.
Aha.. Now I finally understood what means "4Kb boundary" in the datasheet. Thank you very much. That's explains everything.
And as for my case I can note some "incidental" feature: When I set base address as '0x000000' first 16Kb becomes inaccessible. Correct. But after the 0x7FFFF boundary, address expands to the 20 bits address space instead of 19 bits which is actually connected. That's why all address lines becomes zero and in the range of 0x80000 to 0x83FFF EBI acts like it does addressing 0x0000-0x3FFF address range. Because of this the entire 512 Kb of memory is accessible without any troubles.
And it's actually solves my problem  |
|
|
| |
|
|
|
|
|
Posted: Jul 15, 2012 - 08:31 PM |
|


Joined: Apr 29, 2011
Posts: 199
Location: Portland, OR, US
|
|
|
Quote:
But after the 0x7FFFF boundary, address expands to the 20 bits address space instead of 19 bits which is actually connected. That's why all address lines becomes zero and in the range of 0x80000 to 0x83FFF EBI acts like it does addressing 0x0000-0x3FFF address range. Because of this the entire 512 Kb of memory is accessible without any troubles.
That's good to know. I didn't know it worked that way. |
_________________ Gamu The Killer Narwhal
Portland, OR, US
_________________
Atmel Studio 6.1beta on Windows 8
XMEGA-A1/XMEGA-A3BU
AVR Dragon (Ver. 2)
JTAGICE mkII
|
| |
|
|
|
|
|