NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » N00B memory allocation questions

January 04, 2011
by Sciencenerd
Sciencenerd's Avatar

Hello,

While I've been a mainframe assembler programmer for 30 years this is my first foray into microcontrollers. So far so good. I got through the tempsensor project just fine and even have everything working in Eclipse after a dozen hours or so of playing around with it.

I need some clarification on memory. I have the ATMega168 chip. I see from the datasheet that there is 16K of programmable memory, 1K of SRAM and 512 bytes of EEPROM.

Where exactly does the bootloader reside? Is it at the top of the programmable memory? This would mean that I have less than 16K of programmable memory correct?

What is in EEPROM? Nothing? If so then I can store whatever I wish there correct? (With respect to the limited life of EEPROM). Will EEPROM get erased when a new program is loaded(other than the bootloader)?

Is the only purpose of the bootloader to provide logic to load applications? What would be the difference between bootloaders for this chip and say the 32K version?

Thanks in advance to all who help. This looks like a very friendly forum. I'll try and pitch in where I can.

BTW, you guys do it backwards. Bit 0 is on the left :-)

January 04, 2011
by Rick_S
Rick_S's Avatar

The EEPROM is like an old school EPROM except it can be easily erased electronically instead of requiring the UV eraser. As new, the EEPROM is blank and can be used for any purpose you choose, I've used it to store calibration info for an inductive joystick circuit I created. My program would check the EEPROM for a certain value if that wasn't there, it would force a calibration routine to run which would then store it's reference points in the EEPROM for the extreme positions and center positions.

The EEPROM can be erased each time during chip programming... however, I'm not sure if that is what it does in the default configuration... I think it does.

Yes, the bootloader is stored at the top of programmable memory and is protected by fuse bits in the micro to prevent overwriting it. It does eat up a bit of your 16K. As to the difference between the bootloaders, there isn't much other than it has more room to write the program and has been compiled for the bigger chip.

Rick

January 04, 2011
by Hexorg
Hexorg's Avatar

"BTW, you guys do it backwards. Bit 0 is on the left :-)" haha assembler :D

Just wanted to add that you can get a programmer off ebay for 10$ and write code to your chips without the bootloader. All nerdKits bootloader does is allow you to use that usb-to-serial cable instead of programmer.

EEPROM will not get erased when the new program is loaded, unless you tell it to. What are you using to upload your programs? Avrdude? if so, try running avrdude with the -t (terminal) parameter. from there you can give it a command to "read eeprom" or "write eeprom".

By the way, what system are you running eclipse under? Win or linux?

January 04, 2011
by Sciencenerd
Sciencenerd's Avatar

Thanks very much guys.

I'm using AVRdude and the only thing I've done so far is the initialload and tempsensor projects. I've modified tempsensor to blink one LED below a certain temp and another above it. I also figured out how to read data from the serial (USB) port on my PC using puTTY. I'm getting the gist of how this all works. I don't weant to do anything with the EEPROM right now. I'm just trying to understand the environment that I'm working in. I'm not an EE. I'm a software guy - all self taught. Electronics has always been a bit of a mystery to me so I thought this would be a good start.

I do want to try to write to my own chips but that will have to wait until I'm more comfortabale in this world. I may even try my hand at some straight assembly code. We'll see. It's totally different than the IBM instruction set and 8-bit math is a pain in the neck. It takes me back to my 6502 days.

I'm running the latest version of Eclipse Helios under Windows 7. I've used Eclipse off and on for a number of years. I first installed the Java EE version then added the C/C++ plugin, and then the AVR plugin. It took me a bit to figure out that I needed to turn off the automatic generation of the makefile so that it would use the Nerdkit one. In a future project I'll skip the Nerdkits makefile and see if I can get the AVR build process to work for me. I just like working in Eclipse. It's a pretty nice environment with unlimited possibilties.

Post a Reply

Please log in to post a reply.

Did you know that binary numbers use base 2 to represent numbers, and these are important for understanding microcontroller registers? Learn more...