SDRAM Interfacing

OP #1174447
Hi,

I'm using a crossworks 1.7.I have Interfaced a SDRAM K4s561632H with
LPC2478.
I tested it successfully I write some data to it and then read like

  wr_ptr = (UDWord *)SDRAM_BASE_ADDR;
  char_wr_ptr = (UByte *)wr_ptr;
  // Clear content before 8 bit access test
  for ( i= 0; i < SDRAM_SIZE/4; i++ )
      *wr_ptr++ = 0;

  // 8 bit write
  for (i=0; i<SDRAM_SIZE; i++){
  *char_wr_ptr++ = 0xAA;
  *char_wr_ptr++ = 0x55;
  *char_wr_ptr++ = 0x5A;
  *char_wr_ptr++ = 0xA5;
  }

  // verifying
  wr_ptr = (UDWord *)SDRAM_BASE_ADDR;
  for ( i= 0; i < SDRAM_SIZE/4; i++ ){
  if ( *wr_ptr != 0xA55A55AA )  // be aware of endianess
          return FALSE;

  wr_ptr++;
  }

It works perfectly.
My main problem is saving variables in External SDRAM.
cause I have a huge variable arrays.and at the time of building project
it gives error .bss is too large to fit in SRAM memory segment.
like this it gives error for non_init,heap,stack for irq,fiq,und,svc...

I tried to change the size of SRAM from Memorymap.xml and code is built
successfully,but because of that code is not running on hardware.

Please suggest the solution for the same.

Thanks.
Moderator #1174448
John As wrote:
> Hi,
>
> I'm using a crossworks 1.7.I have Interfaced a SDRAM K4s561632H with
> LPC2478.
Did you ask Rowley? Crossworks is a commercial tool and I expect they
offer support for this.

> I tested it successfully I write some data to it and then read like
>
>   wr_ptr = (UDWord *)SDRAM_BASE_ADDR;
>   char_wr_ptr = (UByte *)wr_ptr;
>   // Clear content before 8 bit access test
>   for ( i= 0; i < SDRAM_SIZE/4; i++ )
>       *wr_ptr++ = 0;
>
>   // 8 bit write
>   for (i=0; i<SDRAM_SIZE; i++){
>   *char_wr_ptr++ = 0xAA;
>   *char_wr_ptr++ = 0x55;
>   *char_wr_ptr++ = 0x5A;
>   *char_wr_ptr++ = 0xA5;
>   }
>
>   // verifying
>   wr_ptr = (UDWord *)SDRAM_BASE_ADDR;
>   for ( i= 0; i < SDRAM_SIZE/4; i++ ){
>   if ( *wr_ptr != 0xA55A55AA )  // be aware of endianess
>           return FALSE;
>
>   wr_ptr++;
>   }
>
> It works perfectly.
> My main problem is saving variables in External SDRAM.
> cause I have a huge variable arrays.and at the time of building project
> it gives error .bss is too large to fit in SRAM memory segment.
> like this it gives error for non_init,heap,stack for irq,fiq,und,svc...

Most probably since you have filled up the bss with the huge arrays and
there is not more room.

> I tried to change the size of SRAM from Memorymap.xml and code is built
> successfully,but because of that code is not running on hardware.

I don't use Crossworks but I expect that "Memorymap.xml" is some kind of
control-file for a linker-script generator.

It's difficult to help without locking at least at the startup-code and
the linker-script.

Check the order in the startup-sequence and make sure that the
SDRAM-Controller get initialized before runtime-init of .data and .bss.

As an alternative you might locate you "huge arrays" in a special
section and do the initialization (zero-init) yourself.  See section
attribute in the gcc-manual/Crossworks documenation, check the
Crossworks manual how to configure "Memorymap.xml" to link extra
sections and configure additional memory-areas.
#1174449
You will need to modify the linker script to place data in the external
SDRAM rather than the internal SRAM. The linker is presumably placing
the stack, static data and heap in internal SRAM.

You should configure the SDRAM controller in the C runtime start-up
before stack set-up, static initialisation, and jumping to main().


Note also that executing code from SDRAM is likely to be faster than
from Flash. Also if you are using a 16bit data bus to the SDRAM and
executing from SDRAM you will get better performance using Thumb mode
rather than ARM mode.

Clifford
#1174450
Clifford Slocombe wrote:
> You will need to modify the linker script to place data in the external
> SDRAM rather than the internal SRAM. The linker is presumably placing
> the stack, static data and heap in internal SRAM.
>
> You should configure the SDRAM controller in the C runtime start-up
> before stack set-up, static initialisation, and jumping to main().
>
>
> Note also that executing code from SDRAM is likely to be faster than
> from Flash. Also if you are using a 16bit data bus to the SDRAM and
> executing from SDRAM you will get better performance using Thumb mode
> rather than ARM mode.
>
> Clifford

Thanks for supporting everyone,

              I tried solutions and I found solution on existing
problem.

Now I am facing another problem,with memroy management. My current code
size is exceeds 512k including RODATA. I'm planning to Interface
external parallel flash with this controller.But confusion is How to
write code in internal memory and RODATA in external flash , is there
utility is available by using I can able to program internal as well as
external flash.
             So any idea about this please Its really serious problem
for me...

Thanks

Reply

A question of your own? This thread is over 18 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.