I've got a C5517 development board with 8MB of SDRAM. I've tested it using the CSL example, and that works fine, but I'd like to set it up so that the user can just assign an array to the external ram and then read and write to it normally. As such, I've set up my .cmd file as follows:
-stack 0x2000 /* PRIMARY STACK SIZE */
-sysstack 0x1000 /* SECONDARY STACK SIZE */
-heap 0x6400 /* HEAP AREA SIZE */
MEMORY
{
PAGE 0:
VEC(RWX) : origin = 0000100h length = 000200h
DATA0(RWX) : origin = 0000300h length = 05D00h
DATA1(RWX) : origin = 0006000h length = 0A000h
SARAM0(RX) : origin = 0010000h length = 038000h
SARAM1(RW) : origin = 0048000h length = 002000h
SARAM2(RW) : origin = 004A000h length = 002000h
SARAM3(RW) : origin = 004C000h length = 002000h
SDRAM(RW) : origin = 0050000h length = 800000h
}
SECTIONS
{
vectors : > VEC ALIGN = 256
.text : > SARAM0 ALIGN = 4
.data : > SARAM0
.cinit : > SARAM0
.switch : > SARAM0
.stack : > DATA1
.sysstack : > DATA1
.bss : > SARAM0 , fill =0
.sysmem : > DATA1
.const : > SARAM0
.cio : > SARAM0
.extmem : > SDRAM
USB_buffer1 : > SARAM1
USB_buffer2 : > SARAM2
USB_buffer3 : > SARAM3 , fill =0
GROUP: align(32)
{
.const:twiddle32
.const:twiddle
audio_buffers
fft_buf
} > DATA0
}
then, in my C++ program, I have:
#define RAM_BUFFER_LENGTH 400
#pragma DATA_SECTION(".extmem")
int test_array[RAM_BUFFER_LENGTH];
void testRam()
{
int status;
//Initialize OLED module for status display
disp.oledInit();
disp.clear();
disp.flip();
disp.setline(1);
SDRAM.init();
for (int index = 0; index < RAM_BUFFER_LENGTH; index++)
{
test_array[index] = 17;
}
// for (int index = 0; index < RAM_BUFFER_LENGTH; index++)
{
disp.clear();
disp.setline(0);
disp.print((long) test_array[0]);
disp.setline(1);
disp.print((long) test_array);
}
}
This should print an address in the extmem memory space to the oled display that I have. The value is correct, but the address in DATA0 no matter what I put in my pragma, despite the fact that it compiles -- which it does even if I put a garbage address in it.
Note, that SDRAM.init(); is a wrapper for the CSL EMIF setup function, I get the same behavior without it, but I expect to need to initialize the RAM registers, which this does.
I susupect I'm just using the pragma wrong, but this looks like it matches the compiler user's guide.