This is the quickstart guide for the SDRAM Controller, with step-by-step instructions on how to configure and use the driver in a selection of use cases.
The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function.
Basic use case
In the basic use case, the SDMRAC driver are configured for:
- SDRAM component MT48C16M16A2 is used
- Write/Read access to the MT48C16M16A2
Setup steps
Prerequisites
- System Clock Management (sysclock)
- Parallel Input/Output Controller (pio)
- Power Management Controller (pmc)
Example code
The macro of CONF_BOARD_SDRAMC must be added to the project:
#define CONF_BOARD_SDRAMC
A speicific sdramc device must be defined.
24,
0,
{
SDRAMC_CR_NC_COL9 |
SDRAMC_CR_NR_ROW13 |
SDRAMC_CR_NB_BANK4 |
SDRAMC_CR_CAS_LATENCY2 |
SDRAMC_CR_DBW |
SDRAMC_CR_TWR(2) |
SDRAMC_CR_TRC_TRFC(9) |
SDRAMC_CR_TRP(3) |
SDRAMC_CR_TRCD(3) |
SDRAMC_CR_TRAS(6) |
SDRAMC_CR_TXSR(10)
},
};
Add to application C-file:
Workflow
- Enable the PINs for SDRAMC:
#define CONF_BOARD_SDRAMC
- Initialize the SDRAM device:
- Block1 is at the bit 24, 1(M0)+9(Col)+13(Row)+1(BK1):
- Set SDRAMC to normal mode 0:
- MT48LC16M16A2 has 9 column bits:
- MT48LC16M16A2 has 13 row bits:
- MT48LC16M16A2 has 4 banks:
- Set CAS latency to 2 cycles:
- The data bus width of MT48LC16M16A2 is 16 bits:
- Set Write Recovery Delay to 2 cycles:
- Set Row Cycle Delay and Row Refresh Cycle to 9 cycles:
- Set Row Precharge Delay to 3 cycles:
- Set Row to Column Delay to 3 cycles:
- Set Active to Precharge Delay to 6 cycles:
- Set Exit from Self Refresh to Active Delay to 10 cycles:
- Enable system clock:
- Enable PIO configurations for SDRMAC:
- Initialize MT48LC16M16A2 device:
Usage steps
Example code
Add to, e.g., main loop in application C-file:
uint32_t *pul = (uint32_t *)BOARD_SDRAM_ADDR;
pul[0] = 0xdeadbeef;
if (pul[0] == 0xdeadbeef) {
LED_On(LED0_GPIO);
}
Workflow
- Set the pointer to the SDRAMC address:
uint32_t *pul = (uint32_t *)BOARD_SDRAM_ADDR;
- Write the specific data to the SDRAMC space:
- Read the data, if matched the specific data, turn on the LED0:
if (pul[0] == 0xdeadbeef) {
LED_On(LED0_GPIO);
}