Show Posts
Pages: 1 2 [3] 4 5 6
31  Forum 2005-2010 (read only) / Development / Ok, on to Atmega32 on: October 21, 2006, 10:16:56 pm
Ok, I feel like I really know the Atmega168 now, so now I'm just pushing dev like the kind of project manager we have all hated at some point during our careers. Shoot me if this is going too far.  I have an Atmega32. This thing rocks, hardware-wise.  If Arduino can go  here, at least in the software world, there is no end to what it can do. I see that the Arduino Atmega168 bootloader supports it.  The question is:  what are we going to need to add to the Arduino IDE to support it?  I want an item in the dropdown.  I just tried burning the Atmega168-compatible software to an Atmega32 in an Olimex AVR-P40-USB board and, well, nothing much happened when I then tried to upload an Arduino sketch.  Perhaps someone can shine a light on the differences between an Atmega168 and an Atmega32 and how that applies to the dropdown in the Arduino IDE.  
32  Forum 2005-2010 (read only) / Development / Re: Atmega328P bootloader. etc. on: March 13, 2009, 10:15:20 pm
hmm, well i think you're right nkcelectronics because i have tried several bootloader/sketch upload  cycles, and i can reliably get the sketch to upload precisely once, immediately after uploading a new bootloader.  you've seen the fuses i tried setting. looking around, i've also found the following fuse settings on

avrdude -p m328p   -b56000 -Pcom2 -cponyser   -V -e -U lock:w:0x3F:m -U hfuse:w:0xD8:m

LOCK 328
avrdude -p m328p  -b56000 -Pcom2  -cponyser   -V -U lock:w:0x0F:m

but i'm still getting the same results.  does anyone know the proper AVRdude commands for setting the fuses correctly?  i don't really care to know what the various fuse bits mean (everyone seems to want to talk about this but it just makes my eyes glaze over), i just want the setup that leads to a functional Arduino.
33  Forum 2005-2010 (read only) / Development / Re: Atmega328P bootloader. etc. on: March 13, 2009, 12:40:22 pm
there's definitely something not quite right about Atmega328 support in the stock Arduino 0014 IDE or in my experimentally-modified version.  I suspect there is something subtly wrong with the bootloader (and I've tried several at this point). I can write the bootloaders okay, but 328s with these bootloaders are not plug-in compatible with Atmega168s in an Arduino board (the board I am using is an old NG modified with a 0.1 microfarad capacitor to act like a Diecimila). In the IDE I change the board settings to Duemilanove with Atmega328 and try to upload a sketch and it almost never works. It worked precisely once, causing me to start this thread, but it seems now this success was a fluke.  Does the Diecimila board (or the modified NG board I'm using) not support the atmega328 with bootloader?  Has the auto-reset timing been changed with the Duemilanove?  
34  Forum 2005-2010 (read only) / Development / Re: Atmega328P bootloader. etc. on: March 12, 2009, 11:47:07 pm
i tried the easy way and it kept NOT working. this was partly due to the fact that WinAVR as shipped in Arduino IDE 0014 does not have any references to the Atmega328, so it can't possibly burn a bootloader.  at the minimum you're going to need the latest copy of WinAVR (or whatever AVRdude works in your environment).

with the setup i'm describing, i'm guessing you could use other methods to burn a bootloader, including perhaps the parallel burner.
35  Forum 2005-2010 (read only) / Development / Atmega328P bootloader. etc. on: March 12, 2009, 09:52:34 pm
I'm just collecting together the info I needed to successfully burn an Arduino bootloader onto a 328, which (for those who don't know) gives me twice the RAM, Flash, and EEPROM of an Atmega168.  Getting my setup working wasn't easy, and I had a lot of false starts.

1. Get and install the latest version of the Arduino IDE, which as I write is 0014.
2. Get the latest copy of AVRdude. I'm working on Windows so I got WinAVR. I actually got the latest release candidate, which is  20090306rc1.  You can pick it up here:
3. Inside the Arduino installation folders is this location:
I replaced everything in there with the freshest copy of WinAVR.
4.  In NAME_OF_ARDUINO_FOLDER\hardware\tools\avr\etc is a file called avrdude.conf.  I replaced it with the copy I picked up here:
5. I have an ICSP programming board made from a cheap Olimex board I bought from  I used a serial ICSP connection on COM2 to burn the bootloader found here:
using this command-line command launched from within the WinAVR folder (where I'd put a copy of AT328.hex).

avrdude -F -pm328p -cponyser -Pcom2 -b56000 -u -v  -Uflash:w:AT328.hex

that worked. I then did something I don't fully understand to the fuses:

avrdude -F -pm328p -b56000 -Pcom2  -cponyser  -V -U lock:w:0xCF:m

I took the Atmega328 out and popped it into an Arduino NG board, set the IDE to Arduino Duemilenove w/ Atmega328, hit reset on the board (unnecessary on more modern boards) and successfully uploaded a sketch.  

Twice the Flash means twice the awesomeness!  There were things that had been impossible that now are quite possible.
36  Forum 2005-2010 (read only) / Development / Brownout Detection on: August 11, 2008, 08:56:05 am
Here's a question for those who understand AVR chips inside and out.  I've read that these chips have "brownout detection," though I've never found a good reference for how this is supposed to work.  I'm wondering if brownout detection is entirely a hardware thing or if it is a state that can be read and acted upon by software (possibly requiring an end-run around the normal Arduino environment).  Here's why I'm interested:

My current Arduino project has a "shutdown routine" wherein it writes certain data to EEPROM just before it goes dead (this is mostly to keep the EEPROM from being written to too often and exceeding its 100,000 write cycle limit, although it could have other useful features as well, depending on the answer to this question.)

If brownout detection can be read by software, it would be possible for the Arduino to execute its brief shutdown routine whenever power failed, since there is always enough power left in its discharging capacitors for it to run for a few seconds following a power failure.  This brief source of power quickly falls to a level triggering brownout detection and then, if I can read this from software, I run my shutdown routine.  Please tell me if this makes no sense at all.  Thanks!
37  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: April 07, 2007, 04:21:22 pm
Not that this discussion should be happening here, but I did mail them.

It seems there's a downside to depending on international mail to make people happy.
Obviously, if they don't arrive then you get a refund.
38  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: March 07, 2007, 12:15:06 am
I can assure you that you are imagining the speed difference.  I have used Atmega8s and Atmega168s in the same socket with the same circuitry and have never seen speed differences when executing identical programs, some of which do nothing but record the time, iterate through thousands of loops, and then record the time again.  

Of course, if you have the fuse settings set wrong, it's possible to, say, have the Atmega168 cranking along at only 1MHz, but in those cases its serial port will not work with the default settings for the Arduino IDE and you'd have an objective sense of the problem instead of the subjective one you describe.
39  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: December 03, 2006, 06:50:10 pm
Ok - I made a real page for someone to go to to buy Atmega168/8s preloaded with Arduino firmware.
40  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: November 14, 2006, 09:34:44 pm
Well, interestingly, if you look at its source there appears to be support in the Arduino bootloader code (the version I use for the Atmega168) for the Atmega32 (and other AVR processors not often discussed). The problem is that there is no actual support in the Arduino IDE for Atmega32.   It's crucial that the IDE know about the Atmega32 or it won't be able to do anything. If I was a little more adventurous I would have waded into the IDE source code to see what had changed to add Atmgea168 support and see if those changes, geared to the specifics of the Atmega32, could then added again. But I'd want one of the Arduino old school kids here to point me in the right direction first.
41  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: November 13, 2006, 11:52:08 am
hmm, business opportunity!
paypal me $15 at and send me your snail mail address and i'll make you one.
$10 each for each additional atmega168 in the package.  if lots of people take advantage of this, you might have to wait for me to resupply.
42  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: October 21, 2006, 02:55:20 pm
I kept hearing the term "fuse" and I had no reason to find out what it meant until you mentioned that it was probably my problem. I recommend that anyone who is curious check out this page:

I took a gamble and used the fuse settings you suggested and, happily, my Atmega168 is flashed with a proper Arduino bootloader!  Thanks so much!

For those who need to properly set their Atmgea168 fuses in the future, the AVRdude command line is (depending on your programmer/serial port, I'm using the AVR-PG1 serial dongle on COM1):

avrdude -patmega168 -cponyser -Pcom1 -b9600 -u -v  -Uhfuse:w:0xdf:m -Ulfuse:w:0xc7:m -Uefuse:w:0x08:m
43  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: October 21, 2006, 01:25:51 pm
For the time being I've given up on getting a bootloader to work on my Atmega168. I compiled my Arduino sketch using the Atmega168 processor setting and then went and dug the .hex file out of the applet folder in its project folder.  Then I uploaded it to Atmega168 using AVRdude and the AVR-PG1 dongle.  This all worked fine.

The sketch I'd uploaded has a known behavior of outputting (over the serial output) a line of space-delimited integers every two seconds.  Interestingly, I noticed that though it was working, it was doing so much more slowly than normal and the output was garbled at the expected baud rate.  So I did some experiments by changing the build.f_cpu in the preferences file, ultimately changing it from 16 MHz to just one MHz.  At 1 MHz the baud rate matched the one expected, meaning that somehow the compilation process for the Atmega168 is misjudging the baud rate timing by a factor of 16.  Mind you, I know for a fact that it is actually being clocked at 16MHz (an Atmega8 works exactly as expected in this same socket).  Does anyone have any theories about this peculiar behavior? I have a feeling this all will go a long way to explaining why the Atmega168 bootloader isn't working.
44  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: October 20, 2006, 08:37:14 pm
I know about the processor selection menu and that isn't my problem.  But if you or anyone else can get a dump of the flash memory on a working Arduino Atmega168 and post it here somehow, maybe I could try that out.  I guess you'd have to use avrdude or a program like that - Arduino can't read processors at all.

45  Forum 2005-2010 (read only) / Development / Re: Arduino on the ATMEGA168 on: October 20, 2006, 03:11:23 pm
I just successfully wrote the ATmegaBOOT_168.hex file to my Atmega168 using the AVR-PG1 serial dongle
using avrdude and the command line
avrdude -patmega168 -cponyser -Pcom1 -b9600 -u -Uflash:w:a.hex
(where a.hex is a renamed ATmegaBOOT_168.hex)
What I wouldn't have given for someone to give me a real world example of that program in use!

Now, though, that reflashed Atmega168 is still unrecognized by the Arduino environment.
Has anyone ever used an Atmega168 in an Arduino board?
Pages: 1 2 [3] 4 5 6