I went on a one day Arduino course last week, just for fun, and it got me thinking. I’ve been developing stuff on raw Atmega chips for a while, long before this new-fangled Arduino thing existed, back in the day when you had to write your own display and serial drivers. Anyway, I bought an Arduino Uno Rev3 on that well known on-line auction site at a very reasonable price. And all was well with the world. The Arduino SDK worked with it just fine. But then…
I decided I wanted to use my (homebuilt) STK200 programmer with it so I can use my old code without having to convert my (proper) C code into something called a “sketch”. It didn’t work! Using the JTAG pins I kept getting errors from avrdude that it was the wrong chip!! Further investigation was abviously called for. Looking up the spec for the Arduino I see that it calls for an Atmega328P-PU, looking at the chip on the Uno I see a Atmega328-PU. No “P”. The P designates it as a pico-power chip that’s otherwise identical to the regular one. Basically it has a lower current requirement.
Now the higher current consumption could possibly be an issue for someone using a Chinese Arduino for a battery powered project, or if they are push it to the limit on peripherals and CPU usage there may be an impact on the power supply and on board voltage regulator. I’m assuming, without checking, that these would be over specified anyway.
The main issue was I couldn’t upload any code. As by now I’d messed with the bootloader and neither the serial upload using the Arduino SDK or the parallel, STK200 worked. One wat thought is was a m328p chip and refused to upload, the other way thought is was an m328 (no ‘p’) and again refused to upload. The problem and solution lay within the various config. files used by the SDk and avrdude. On Linux there’s a config file in ~/.arduino name preferences.txt. First this had to be edited to get the STK200 working.
In ~/.arduino/preferences.txt change:
and lower down the file,
Next edit /etc/arduino/programmers.txt to add the STK200 programmer to the arduino list by adding the following to the bottom of the file.
Then as root again we need to edit /etc/avrdude/avrdude.conf by adding another section for the ATmega328. Because there isn’t one for the -m328 at all, just the -m328p! Do this by copy/paste the ATmega328P section, editing the descriptive fields and changing the signature to 0x1e 0x95 0x14 from 0x1e 0x95 0x0f.
So three files have to edited to get these cheaper Aduinos to behave. To be fair most people could happily program these with their “sketches” via the Ardiono SDK and never know the difference. Some of us though aren’t satisfied with that and want to get our hands/brain inside the little beasties to tweak and trim as we please without the nice comfort of it all being hidden behind the niceties of the SDK. I’d save a couple of quid but it cost me in time. Still all learning is good and I consider that time well spent.