µTasker Forum
µTasker Forum => ATMELTM AT91SAM7X and AVR32 => Topic started by: kmjackson on September 27, 2011, 07:14:12 AM
-
Hi Mark,
Do have any code that initializes the SDRAMC and make use of it? I want to use it for heap.
Thanks,
Kenneth
-
Hi Kenneth
I have code for SDRAM initialisation on the AVR32 (but nothing for the SAM7). The code is based on ATMEL examples so if you look in the ATMEL framework you will be able to find similar initialisations:
volatile int i;
POWER_UP(PBB, (PBBMASK_SDRAMC)); // power up the SDRAM controller
POWER_UP(HSB, (HSBMASK_EBI)); // and external bus interface
// SDRAM interface
//
_CONFIG_PERIPHERAL_A(2, (EBI_DATA_0_A | EBI_DATA_1_A | EBI_DATA_2_A | EBI_DATA_3_A | EBI_DATA_4_A | EBI_DATA_5_A | EBI_ADD_0_A | EBI_ADD_2_A | EBI_ADD_3_A | EBI_ADD_4_A | EBI_ADD_5_A | EBI_ADD_6_A | EBI_ADD_7_A | EBI_ADD_8_A | EBI_ADD_9_A | EBI_ADD_10_A | EBI_ADD_11_A | EBI_ADD_13_A | EBI_ADD_14_A | EBI_ADD_16_A | EBI_ADD_17_A));
_CONFIG_PERIPHERAL_A(3, (EBI_DATA_6_A | EBI_DATA_7_A | EBI_DATA_8_A | EBI_DATA_9_A | EBI_DATA_10_A | EBI_DATA_11_A | EBI_DATA_12_A | EBI_DATA_13_A | EBI_DATA_14_A | EBI_DATA_15_A | EBI_NWE_1_A | EBI_NCS_1_A));
_CONFIG_PERIPHERAL_C(1, (EBI_SDA_C | EBI_SDWE_C | EBI_SDCK_C | EBI_SDCKE_C | EBI_CAS_C | EBI_RAS_C));
// The SDRAM initialisation is a slim-line copy of the ATMEL reference code set up for this SDRAM type and speed
//
HSB_READBACK(SFR5, SDRAM_CHIP_SELECT);
SDRAM_READBACK(CR, (0x421131d9)); // SDRAM configuration
SDRAM_READBACK(MR, SDRAM_MODE_NOP); // issue NOP in oder to start the generation of SDRAMC signals
SDRAM_READ(); // dummy read from SDRAM
for (i = 0; i < 2000; i++) {} // 200us delay
SDRAM_READBACK(MR, SDRAM_MODE_ALL_BANKS_PRECHARGE); // issue a PRECHARGE ALL command to the SDRAM.
SDRAM_READ(); // dummy read from SDRAM
for (i = 0; i < 5; i++) {} // 15ns delay
SDRAM_READBACK(MR, SDRAM_MODE_AUTO_REFRESH); // issue auto-refresh command twice for this device
SDRAM_READ(); // dummy read from SDRAM
for (i = 0; i < 10; i++) {} // 66ns delay
SDRAM_READ(); // dummy read from SDRAM
for (i = 0; i < 10; i++) {} // 66ns delay
SDRAM_READBACK(MR, SDRAM_MODE_LOAD_REGISTER); // commit settings
SDRAM_READ(); // dummy read from SDRAM
for (i = 0; i < 5; i++) {} // 2 cycles delay
SDRAM_READBACK(MR, SDRAM_MODE_NORMAL); // set normal mode
SDRAM_READ(); // dummy read from SDRAM
SDRAM_READBACK(TR, 0x176); // set timing register, after which the SDRAM can be used
Regards
Mark
-
Mark,
I'm actually using an AVR32. It this code snippet already in the uTasker project; I can't find it.
Kenneth
-
Kenneth
The code is from a uTasker 'based' project but it is not in the present AVR32 version (I had it in fnUserHWInit() in application.c). It is for an 32UC3A512 and works with the SDRAM oin the EVK1105 - other SDRAM types may need adjustments (?).
Regards
Mark