This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C5517 SDRAM Mapping

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.

  • Hi William

    The first thing that I suggest you do (you may already did it) is to look at the map file  (it is in the debug or the release directory) and verify that all the global variables are in the correct addresses. A word of caution - I think that the cmd file specifies sizes in words (2 bytes) while the map file gives the sizes in bytes.


    The next step after verifying that the map file is what you expect is to debug the code. I assume that you built the project with no optimization and full symbolic debug information.  So step in the code and after every instruction check the values of the variables. Look what is the address of test_array and see if the code loads it with 17. You can browse the memory (open memory brows from the view tab and put the name tast_array in the address tab. You will be able to see what is the address of test_array and how it loads the value 17.     

    Post your observation.  If you figure out what is the problem tell us and then close the thread

    regards

    Ran