I have a custom board for my project with standalone arduino Uno/Atmega 328 chip.
Im using USBtinyISP as the programmmer along with Arduino IDE.
I need to pre-programmed some EEPROM data into the Atmega 328.
The main program will only used this EEPROM data for first time power-up and then will change the value based on sensor calibration.
Right now, the EEPROM data is erased everytime I upload program to the chip via ISP headers.
I read that I need to change the fuse bits so but not sure how do I do this..
What do you select from the Tools > Board menu when you want to upload to your custom board? If it's a 3rd party platform you installed then post a link to where you downloaded it from.
This will set the fuses and also burn the bootloader. I know you don't need the bootloader since you're uploading via Sketch > Upload Using Programmer but the bootloader will just be erased the next time you upload so it doesn't make a difference other than taking a little more time to set the fuses, that's just the way the Arduino IDE it set up to work. You can use the same process to adjust any of the fuse setting you like. I use this fuse calculator: AVR Fuse Calculator for ATmega328P. As you can see, the high fuse value of D2 is the same as the original boards.txt file's high_fuses value of DA except that the EESAVE bit has been changed from 1 to 0, which will cause EEPROM memory to be preserved through the chip erase cycle.
Note that the boards.txt file used may revert to the original settings when you update your IDE version or install a new Arduino AVR Boards version. This will only affect you if you do Tools > Burn Bootloader. Sketch > Upload Using Programmer doesn't change your fuse settings. If you end up wanting to keep a customized boards.txt file separate from the Arduino AVR Boards boards.txt it's fairly easy to install one at {sketchbook folder}/hardware. This file will not be affected by any IDE or Arduino AVR Boards updates. I can provide more information if you want to do that.
pert:
This will set the fuses and also burn the bootloader. I know you don't need the bootloader since you're uploading via Sketch > Upload Using Programmer but the bootloader will just be erased the next time you upload so it doesn't make a difference other than taking a little more time to set the fuses, that's just the way the Arduino IDE it set up to work. You can use the same process to adjust any of the fuse setting you like.
TQVM on the detail explanation!
Will setting the high fuse (EESave) via board.txt will help me to maintain the EEPROM value after new program upload?
Prior to this, I developed my program using Arduino Uno board. First I upload the program with eeprom_put function to burn the initial EEPROM value, and then I upload my actual program. Now that I have a custom board and upload the program using USBtinyISP, this method doesnt work anymore because the EEPROM is cleared.
Sorry for the noob question...
pert:
If you end up wanting to keep a customized boards.txt file separate from the Arduino AVR Boards boards.txt it's fairly easy to install one at {sketchbook folder}/hardware. This file will not be affected by any IDE or Arduino AVR Boards updates. I can provide more information if you want to do that.
Yes, I would like to learn how to create customized board.txt. However I'm using macbook, is the steps going to be similar?
It's easier for me to just create one for you than explaining all the steps but I think you will be able to use this and the stock Arduino boards.txt file as a reference for any other files you want to create or any changes you want to make. There is more information at: Arduino IDE 1.5 3rd party Hardware specification · arduino/Arduino Wiki · GitHub.
Installation instructions:
Download the attached file
Copy the enclosed folder MsMocha to {sketchbook folder}/hardware. If a hardware folder doesn't already exist then create one. You can find the location of your sketchbook folder in the Arduino IDE at File > Preferences > Sketchbook location
Restart the Arduino IDE
Select Tools > Board > MsMocha's Pro or Pro Mini
You can edit any of the settings for the board at {sketchbook folder}/hardware/MsMocha/avr/boards.txt.
Currently the only purpose of {sketchbook folder}/hardware/MsMocha/avr/platform.txt is only to give a name to the Board menu section for your board but you can add recipes to that file to give you control over the toolchain, for example setting different compiler optimization level. See the platform.txt incuded in Arduino AVR Boards for examples.
I included an empty bootloader file. This will speed up the Burn Bootloader process which requires a bootloader file(unless you create a custom recipe in your platform.txt to change that behavior). This bootloader doesn't actually do anything but that doesn't matter because you're doing Upload Using Programmer.
I set it up so that you can just click the regular upload button and it will automatically do an Upload Using Programmer.