excecuting through SRAM

Started by M Habib July 2, 2005
hi everybody
how can i excecute a program written on the sram using AT90S8515 or ATmega8515?

also how can i use the spm instruction to write one word only in the flash mem. using the ATmega8515??

thanx ---------------------------------
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football



On Sat, 2 Jul 2005, M Habib wrote:

> hi everybody
> how can i excecute a program written on the sram using AT90S8515 or ATmega8515?
>
> also how can i use the spm instruction to write one word only in the flash mem. using the ATmega8515??
>
> thanx
>

Have you downloaded the data sheet for the 90S8515 and studied it in
detail? The answers to your questions are all in the data sheet, and it's
free. You just have to take the time to download it.

You can't execute a program from SRAM in the 8515, BTW.

Zack


At 03:57 AM 7/2/2005, M Habib wrote:
>hi everybody
>how can i excecute a program written on the sram using AT90S8515 or
>ATmega8515?

Well.. The processor won't execute code from there, but you could
store instructions there that are acted on by a bytecode interpreter.
It's a moderately advanced project though..

I wrote the kernel of one, and put it out for the public in my old
"getting started" code. Yikes, was that actually five years ago?
It ran bytecode stored in EEPROM, but there's no reason you couldn't
have the bytecode in ram.
I only implemented a few instructions in the example, but the whole
point was to illustrate how to do it, so you can write instructions
that are well suited to your application.


Doing a driveby in the group...may not follow things up later

There ARE some microcontrollers with the ability to execute code out
of their program memory AND (without resetting) code stored in SRAM.
Code stored in SRAM of course has a stiff penalty in execution
times...but it still works pretty darned fast. A couple of the PIC18
series so it and one of the Atmel 8051 type MCU's can do it.

The Atmel chip has 4k of program memory which is mapped on top of
external program memory. External program memory is ASSUMED to be
FLASH, ROM, EEPROM, etc...but there's not really any big difference
between the interface. The one minor issue (and it can be an
advantage) is that the MCU differentiates between program memory and
external SRAM with a line that you run to the chip enable of your
respective memories (obviously setting the logic properly to activate
each chip at the right time) BUT...you can just leave the control
line alone...which would have the affect of making your external
program memory AND your SRAM...the same memory (so you can easily
read and write to program memory)
...again, this isn't an AVR chip and so far as I can see there are
few versions of this chip available.

Oh, and there are apparently some USB microcontrollers that actually
boot from serial EEPROM and execute all their code out of SRAM
--- In avrclub@avrc..., Dave VanHorn <dvanhorn@d...> wrote:
> At 03:57 AM 7/2/2005, M Habib wrote:
> >hi everybody
> >how can i excecute a program written on the sram using AT90S8515
or
> >ATmega8515?
>
> Well.. The processor won't execute code from there, but you could
> store instructions there that are acted on by a bytecode
interpreter.
> It's a moderately advanced project though..
>
> I wrote the kernel of one, and put it out for the public in my old
> "getting started" code. Yikes, was that actually five years ago?
> It ran bytecode stored in EEPROM, but there's no reason you
couldn't
> have the bytecode in ram.
> I only implemented a few instructions in the example, but the whole
> point was to illustrate how to do it, so you can write instructions
> that are well suited to your application.



>
>The Atmel chip has 4k of program memory which is mapped on top of
>external program memory. External program memory is ASSUMED to be
>FLASH, ROM, EEPROM, etc...

There IS NO external program memory in the AVR.
There is external data memory.
No Go Joe.


--- In avrclub@avrc..., Dave VanHorn <dvanhorn@d...> wrote:
>
> >
> >The Atmel chip has 4k of program memory which is mapped on top of
> >external program memory. External program memory is ASSUMED to be
> >FLASH, ROM, EEPROM, etc...
>
> There IS NO external program memory in the AVR.
> There is external data memory.
> No Go Joe.

I did in fact say that it was one of their 8051 variants.

I quote (me)
"A couple of the PIC18 series so it and one of the Atmel 8051 type
MCU's can do it.
The Atmel chip has 4k of program memory which is mapped on top of
external program memory..."

Just thought it was worthy of mention



>
>The Atmel chip has 4k of program memory which is mapped on top of
>external program memory..."
>
>Just thought it was worthy of mention

There's the thing though. Although the addresses overlap, you won't
find instruction fetches accessing the SRAM no matter what you do.
So, you can't get there from here, at least in the current parts.

Pity, it would be fun.
I've done self-modifying code before, in a couple of different
bytecode interpreters, including one I wrote for the AVR, but that
code lived in EEspace.
Still, you could move that to SRAM easily enough.


No, you misunderstand. It maps the 4k on top of the external program
memory...meaning that you simply can't access the lower 4k of SRAM as
program memory. If you have it execute any address above the
internal 4k, it fetches the instruction from SRAM.

...and here's the datasheet (NOTE: this is NOT an AVR)
http://www.atmel.com/dyn/resources/prod_documents/doc3053.pdf

...and in that datasheet it CLEARLY states

"If the EA pin is connected to GND, all program
fetches are directed to external memory. On the
AT89LS51, if EA is connected to VCC, program
fetches to addresses 0000H through FFFH are
directed to internal memory and fetches to
addresses 1000H through FFFFH are directed to
external memory."

And this chip is relatively inexpensive. $2 or so from digikey.
--- In avrclub@avrc..., Dave VanHorn <dvanhorn@d...> wrote:
>
> >
> >The Atmel chip has 4k of program memory which is mapped on top of
> >external program memory..."
> >
> >Just thought it was worthy of mention
>
> There's the thing though. Although the addresses overlap, you won't
> find instruction fetches accessing the SRAM no matter what you do.
> So, you can't get there from here, at least in the current parts.
>
> Pity, it would be fun.
> I've done self-modifying code before, in a couple of different
> bytecode interpreters, including one I wrote for the AVR, but that
> code lived in EEspace.
> Still, you could move that to SRAM easily enough.


At 12:36 PM 7/6/2005, poitsplace wrote:
>No, you misunderstand. It maps the 4k on top of the external program
>memory...meaning that you simply can't access the lower 4k of SRAM as
>program memory. If you have it execute any address above the
>internal 4k, it fetches the instruction from SRAM.

Yes, I was speaking of the AVR. I know other devices do this, but the
AVR does not.


Seems to me that if you want code and data accessed in the same memory
space, then you want a chip/CPU with a classic von Neuman architecture
rather than a Harvard architecture with separate data/code spaces.
But this is too obvious, eh? Maybe you guys are just chatting about how to
coerce the Harvard chip.

-----Original Message-----
From: avrclub@avrc... [mailto:avrclub@avrc...] On Behalf Of
Dave VanHorn
Sent: Wednesday, July 06, 2005 10:45 AM
To: avrclub@avrc...; avrclub@avrc...
Subject: Re: [AVR club] excecuting through SRAM

At 12:36 PM 7/6/2005, poitsplace wrote:
>No, you misunderstand. It maps the 4k on top of the external program
>memory...meaning that you simply can't access the lower 4k of SRAM as
>program memory. If you have it execute any address above the
>internal 4k, it fetches the instruction from SRAM.

Yes, I was speaking of the AVR. I know other devices do this, but the
AVR does not.

Yahoo! Groups Links