New Arduino user here... Been making a ton of progress on my project (guitar pedalboard controller)...
I'm using the extended DB library to keep "presets" stored on eeprom. I was hoping to have one sketch to store the presets in eeprom,
and then my regular sketch to run the pedalboard and simply read them. However, when I upload a new sketch, eeprom seems to be cleared... is there any way to tell Arduino not to clear the eeprom upon sketch upload?
The ATmega328P processor has an EESAVE fuse which controls this behavior. To change the value of this fuse you will need an ICSP (in-circuit serial programmer) which connects to the 2x3 pin header next to the microprocessor. I like Atmel's ATAVRISP2 programmer which, at $35, is not the least expensive solution but it's never let me down across all types of Atmel's processors. You would then use Atmel's AVR Studio (or AVRDUDE by itself if you're comfortable mucking with fuses at the command line) to connect to the processor using the ATAVRISP2, change the EESAVE fuse, and then you should be all set.
--
The Rugged Audio Shield: Line In, Mic In, Headphone Out, microSD socket, potentiometer, play/record WAV files
Thank you for this info! I am using your Flexible Midi Shield for this project and it's working great!
I'm curious - if I were to use external eeprom or SD to store these presets would they require the fuse change, or would they retain their data by default? Wondering if it's more efficient for me to go that route than to purchase this programmer just to change one setting? Maybe the programmer would be useful for me down the line...? Maybe the SD would slow things down?
External EEPROM or SD would store anything you write to it -- uploading sketches wouldn't affect that.
Whether it's more efficient for you to go that route....it wouldn't be for me Doing a little surgery on an Arduino with a $35 programmer makes more sense to me personally than adding extra hardware and complexity. And the programmer is definitely useful down the line if you plan to work with other devices.
If you are really cost conscious you can use another Arduino board as an ICSP programmer. It just takes a lot of reading, experimenting, and patience For me, the AVR ISP is one of the tools I always have on the bench, next to the FTDI serial cable, a couple of screwdrivers, two DMM's, and a cup warmer.
--
The Basic Motor Driver: simple, inexpensive motor driver for 1 stepper motor or 2 DC motors
it shows preserve eeprom memory through chip erase cycle as disabled.
If I check that box, the fuse setting is changed to
0xFF 0xD6 0xFD
the extended fuse value of 0xFD is equivalent to 0x05, so the only thing that changed is the EESAVE value of high fuse.
same for atmega2560
boards.txt fuse setting says
0xFF 0xD8 0xFD
if I check preserve eeprom, the fuse settings change to
0xFF 0xD0 0xFD
if you have another uno or mega, you can use arduino as isp sketch to change the fuse setting. just change the value in boards.txt and burn the bootloader on the target. if you want to get a programmer, you can get a usbasp for under $4 on ebay.
if uploading sketch via bootloader, the avrdude command is like
avrdude -CE:\arduino-1.0\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P\.\COM1 -b115200 -D -Uflash:w:C:\TEMP\build3958906321873940373.tmp\Blink.cpp.hex:i
which is independent of the fuse setting as you said.
if you say burn the bootloader, the avrdude command is
avrdude -CE:\arduino-1.0\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\.\COM1 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xde:m -Ulfuse:w:0xff:m
the fuse values are obtained from board.txt, so you can either change it in boards.txt or just run avrdude from command line with the fuse values needed.
now come to think of it, I think the OP problem is not due to fuse setting. I think the db library may be clearing the eeprom.
I didn't get notifications on these replies so apologies for my absence
I will look into the DB library, perhaps there is a setting I can adjust. I've been more focused on the hardware side of things and getting the thing up and running in a state where at least I can play music with it...
Just spend a few hours on a 328p-au chip to upload sketches via ISP and 'remembering' EEPROM.
One thing to keep in mind using ISP, it seems the fuses are only set while burning a bootloader, and not while uploading a sketch with a programmer. After changing the fuse settings in boards.txt (as explained by doughboy) and burning a bootloader it works.
Thanks you for the information to figure this one out!
I have a question somewhat related to this topic. My bog standard arduino (2009 flavor) with bootloader uploads just fine with the normal IDE upload command via USB serial. However if I then take my TinyUSB ICSP programmer and use the IDE's file menu "upload using programmer" option then it too burns the sketch fine into the board, however the bootloader gets erased (I checked after burning the sketch by reading flash content with a AVRDUDE standalone GUI program). So how did the fuse setting get changed such that the bootloader code was not protected as it normally gets protected using the standard USB serial uploading?