External RAM and I/O

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using AVR-GCC to develop a system with external RAM and I/O. Beside the inline assembler (because it is too complicated for me), what will be the most efficient coding for accessing the external RAM and I/O.

I tried the following statements:

#define IOPORT 0xf000
char j;
*(char *) IOPORT=j;

I find that the statement is masked out something by the compiler by looking at the assembly listing file. Could anybody help. Thanks a lot!

Vincent

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Vincent,

If you just want to use the external RAM, you need to first enable the External SRAM interface by setting the SRE bit (and maybe the SRW bit) in the MCUCR register :

sbi(MCUCR, SRE);
sbi(MCUCR, SRW); // set this if you need wait states

You can then access the SRAM through pointers as normal :

char *some_sram_address = 0x1000; // this points to SRAM
char *str = "This is a string"; // this is in code memory

// copy string to RAM
strcpy(some_sram_address, str);

// print string (from RAM)
printf("RAM String = %s",some_sram_address);

/Jesper
http://www.yampp.com
http://www.myplace.nu

/Jesper
http://www.yampp.com
The quick black AVR jumped over the lazy PIC.
What boots up, must come down.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I was wondering how people debug in avrstudio using gcc, I know that the debug symbols
don't work for setting watches , so how do you monitor a variable while not knowing
much about assembly. I understand that you need to look at the memory location directly
but how do you find out the mem location.

Thanks in advance,

Russ.

admin's test signature