Board Programming

Hello all,

I am new to this forum and to everything dealing with robot controllers and programming in generall :smiley: . I am working on a project for work and am getting ready to program my baby-O 328p. the program is a simple ( by simple, I mean it took me a while to do what would take the most of you 10min to do lol) DC motor control that allows me to control direction and the time running in each direction. I figure that the settings in the code are just a first test to see what positions the motor is going to turn to. I am pretty sure that I will have to change speed, delay settings or both to get the desired positions I require.

My questions is, after I program the board the first time what happens when I have to change the settings and reprogram the board? Do i just have to go through the same programming steps and it writes over the original program, or do I have to erase the board first before I reprogram it? I realize memory is limited and I also don’t want to glitch the board or my program by making a simple mistake.

I look forward to all your responses, and thanks for the help. Cheers!

It is necessary to erase the flash program memory on the AVR before programming a new program on to it. But most programming software (e.g. avrdude and AVR Studio) will take care of doing this for you, so you don’t need to worry about it. Just do the same steps that you did to program it the first time.

One nice thing about microcontrollers with flash memory is that you can re-write them thousands of times (10,000 times on the Mega328p) so you have the flexibility to make lots of little changes to your program.



Thank you for your simple and straight forward reply. I am using AVR Studio so am I to assume that it will prompt me to clear the flash memory or is this an extra step or setting that I will have to engage myself? I figured that the board would be reprogrammable, but as this is not my specialty I just wanted to clear the air of any doubt I had in doing it.

Thanks again David,



AVR Studio is configured by default to automatically sends a chip-erase command before programming the device, so you don’t have to worry about taking any special extra steps. Just program the chip as the user’s guide indicates and you’ll be fine. If you use AVRDUDE, including a “-e” at the beginning of your command results in an initial chip erase.

- Ben

If you tell avrdude to write to flash, it will automatically erase the flash first, without the need for the -e option. This feature can be disabled using the -D option.