external memory mapping more than 64KB

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

Hi all:

I was thinking on how to access more than 64KB space of external memory on avr (Mega128) with C. But is seems a bit complicated since I´d need more pins to access the memory and a corresponding routines to point the ext hardware to the correct page.

Did anybody here something like this before? Also I need to have separate IO space (toggling a pin on the AVR, so this pin colud be named "IO/MEM".

I think the real problem arises when there´s an interrupt wanting to access an array in ext memory, but this interrupt happens just after taking high the IO/MEM pin, so the the absolute memory map is pointed to IO.

Is the correct synchronization on a system like this achievable by means of a Linker description file? or there´s something more to do?

Thanks

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

Hello,

Quote:
I was thinking on how to access more than 64KB space of external memory on avr (Mega128) with C. But is seems a bit complicated since I´d need more pins to access the memory and a corresponding routines to point the ext hardware to the correct page.

Did anybody here something like this before? Also I need to have separate IO space (toggling a pin on the AVR, so this pin colud be named "IO/MEM".

I'm right now working on a project consisting of an ATmega128L 3.3v 7.3728 MHz with 1 1MB 90ns parallel Flash ROM IC and 2 512KB 70ns parallel non volatile SRAM ICs (battery backed with a supervisor). This is addressed as 64 32KB memory banks placed in the top 32KB of the external memory bus addresses and decoded with 6 additional port pins, with different wait states for the devices. Some of the high addresses in the first 32KB of the memory are reserved for I/O. Joined to the JTAG ICE is almost a dream to an embedded software developer.

My first tests haven't dropped any problem till the moment. I am developing in C with avr-gcc. I have defined macros to read and set the memory bank to be accessed, and to set the wait states for the different peripherals.

Banked memory addressing is an embarrasment. To simplify the access I have developed a huge memory model with several functions to bypass the banking model in non time-critical code and linearize the whole memory space using 32 bits long data as "huge" pointers with byte, word, double word and block reading and writing routines (well, writing in the flash is a bit more complicated). I'm also thinking about adding a filesystem to manage to store information in several contiguous memory banks in a named, variable size, file fashion.

Quote:
I think the real problem arises when there´s an interrupt wanting to access an array in ext memory, but this interrupt happens just after taking high the IO/MEM pin, so the the absolute memory map is pointed to IO.

Is the correct synchronization on a system like this achievable by means of a Linker description file? or there´s something more to do?

The problem with the interrupts in my case is not so important because I'm using the internal 4KB of SRAM to hold the stack frame (it's the fastest RAM, and in C there are generally many function calls). It's also possible to use any other non overlapped address block but it wouldn't be so fast. In the interrupt service routines care must be taken in preserving the selected bank to restore it before returning. In a similar manner a RTOS with preemptive task switching should have a mechanism to preserve the "memory status" as part of the task context, like the stack pointer, the status register or the R0-R31 register set.

It's easy!

Regards. Carlos.