This is the quick start guide for the EBI Driver, with step-by-step instructions on how to configure and use the driver for specific use cases.
The section described below can be compiled into e.g. the main application loop or any other function that might use the EBI functionality.
Basic usage of the EBI driver would be to interface external SRAM/SDRAM. Our specific use case will cover usage of SDRAM.
A basic use case for the EBI driver would be to interface SDRAM, and in this specific case, interfacing the on-board 8 MB SDRAM chip of the XMEGA A1 Xplained board. The module is connected in three-port mode, utilizing 12 address lines. The timing information in the configuration of the device is specific to this chip. You may directly use the source code if you are using the same chip (or board), otherwise you should refer to the SDRAM chip's data sheet for specific timing information.
To be able to interface the external SDRAM module, the Data in Huge Data Memory Space (hugemem) module must be included and enabled. This is done by selecting the hugemem module from ASF, and including the line
in your source code. We also need some information about our chip, such as address start, size of usable memory, refresh rate and initialization delay.
Include string.h for memset() and strlen() functions:
After the board has been initialized, we need to initialize the EBI driver. We need two configuration structures to configure the driver:
We set up the EBI driver for three-port, 12 address line SDRAM operation:
We set the chip select mode to SDRAM, address space size to 8 MB, and the base address:
We want normal SDRAM operation:
SDRAM is organized in rows and columns, and we want 12 rows and 10 columns:
The timing information for our device is:
Set all timing information:
Our configuration is complete, now we write it to the device:
And enable the chip select for the device:
Now we wait for the EBI driver to initialize and be ready for use:
The EBI is now configured and running. We will write a string to memory, and read it back again.
We declare the size of our data chucks, a hugemem-pointer which we will use to point to SDRAM, a chuck of data, and a chuck to read into.
We point the pointer to the beginning of SDRAM.
We zero out the read_data variable to make sure its empty.
We now write the data to SDRAM.
The ptr variable now points to the end of the string, so reset it.
We now read the data back into the read_data chuck:
The read_data variable now contains the same as the data variable.