Can any microcontrollers compile code into RAM?

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Can any microcontrollers compile code into RAM?

Postby Chuckz » Fri Feb 08, 2013 9:11 am

I have a friend who has a question about the various microcontrollers. Can someone please answer this for different microcontrollers?

Can any of them compile their own code into RAM, and execute it from RAM? The PICs I'm familiar with definitely cannot. Every little change in the code requires powering down and re-programming the program flash memory, and then powering back up. IOW, every itty bitty change presents a total disruption in what the µC was doing.
Chuckz
 
Posts: 140
Joined: Mon May 30, 2011 10:54 am

Re: Can any microcontrollers compile code into RAM?

Postby adafruit_support_rick » Fri Feb 08, 2013 10:45 am

That's a pretty broad question - there are lots of microcontroller architectures out there.

I can start answering it by telling you that most microcontrollers use what is known as a "Harvard architecture", which means that program space and data space are on different internal memory buses. This is a speed optimization which allows instructions and data to be accessed in parallel (i.e., simultaneously). It also means that the processor cannot execute instructions from data space.

Desktop and other general-purpose computers typically use what is known as a "Von Neumann architecture", which has a single address space for both instructions and data.

Von Neumann architectures are much more flexible, and so they are well-suited to general computing where many different programs can be loaded and executed dynamically. But they are also subject to errors caused by bugs which lead to the execution of data as instructions. Viruses exploit this weakness by disguising their code as data and then causing the processor to execute it.

Microcontrollers, on the other hand, are not intended for general computing. They are designed to be embedded in a purpose-built device, and committed to a specific set of tasks. Harvard architectures are well-suited to this, since a non-volatile, read-only program space is highly desirable - programming errors (or viruses) cannot modify or damage the program, power failures cannot erase the program, etc.

There are far too many microcontrollers for me to catalog, but off the top of my head I can tell you that the Atmel AVR family and the Intel 8051 family are both Harvard architecture.
User avatar
adafruit_support_rick
 
Posts: 2875
Joined: Tue Mar 15, 2011 10:42 am
Location: Buffalo, NY

Re: Can any microcontrollers compile code into RAM?

Postby westfw » Fri Feb 08, 2013 12:35 pm

The TI msp430 CPUs are Von Neumann, and can execute code from ram.
unfortunately, they don't usually have much ram.
User avatar
westfw
 
Posts: 1321
Joined: Fri Apr 27, 2007 12:01 pm
Location: SF Bay area

Re: Can any microcontrollers compile code into RAM?

Postby franklin97355 » Sat Feb 09, 2013 12:54 am

The Parallax Propeller also can compile into RAM and run the code until powered down.
User avatar
franklin97355
 
Posts: 1706
Joined: Mon Apr 21, 2008 1:33 pm

Re: Can any microcontrollers compile code into RAM?

Postby thefatmoop » Sun Feb 17, 2013 4:21 pm

Yeah Frank beat me to it. the parallax propeller can have the compiled code tossed directly into ram which is seriously fast and convenient.

but that's about the only plus to the propeller. I'd suggest you avoid it

now if he means compile it's own code that sounds more like an os and you're not going to find that in a micro. raspberry pi is an option
thefatmoop
 
Posts: 220
Joined: Tue Aug 19, 2008 3:36 pm


Return to Microcontrollers

Who is online

Users browsing this forum: No registered users and 2 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]