The ProtoStack ATmega328 Development Kit came in a well packaged antistatic bag that had individual heat sealed sections for the PCB and components. I also got a free USBasp programmer which I was not expecting (Thanks ProtoStack!). I did have an Atmel JTAG ICE mk-II that I was planning on using to program the ATmegga328, but the USBasp is a bit more compact and I thought I'd use that instead.
The ProtoStack User's Guide for the ATmega328 kit is very well laid out and is easy to follow. They have put a lot of effort documenting different build configurations to easily change how the board is powered or programmed. They clearly document how to power the board with a DC Jack, USB Device, Coincell CR2032 Battery, or Terminal Block. They also show how to add board stacking connectors.
It took less than 30mins to solder up the kit. I did make a few small tweaks to my build. The kit comes with a 20MHz Xtal, but I wanted my board to be Arduino sketch compatible so I installed a 16MHz Xtal instead. I also added a ST Micro ST232CN RS232 level converter (connected to D0 [Rx] and D1 [Tx] and a DB-9 female connector. This RS232 connection allows me to use a USB-to-RS232 dongle to connect this kit to my computer and download sketches from the Arduino IDE. I love that the standard Arduino's come with the USB Device interface built in, but having a native RS232 interface on this kit helps me connect to all my legacy peripherals that still use RS232. I also connected up a Parallax 16x2 Serial LCD by hooking up the RX pin of the LCD display to the D1 [Tx] pin of the micro and hooking up 5V and GND of the display to the boards power rails.
For kicks I added one of Adafruit's cool ATmega 168/328 labels on the micro, so I don't have to grab the schematic or datasheet when doing a quick measurement or mod.
Overall I was extremely happy with how quickly the ProtoStack ATmega328 kit went together; my one complaint is that ProtoStack provides very little programming tutorial help other than pointing to several third party USBasp compatible websites/software. The struggle I had was all of these websites assumed the user had a basic understanding of programming Atmel AVR's which I didn't. All I had done before is used the Arduino IDE to program parts that already had the Arduino bootloader installed.... so that was my first step, I needed to use the USBasp to program in the Arduino bootloader then I should be able to use the RS232 interface to load sketches onto this board.
The first thing I did was download Atmel's AVR Studio for Windows. I got that installed and was surprised to find that even though the USBasp programmer had a windows driver it was not compatible with AVR Studio.... fail. So I grabbed my mk-II programmer I had gotten from a friend and was surprised to find that I could not get that to work either..... double fail. It turned out that the mk-II programmers USB Device interface was broken and it worked fine if I used its RS232 connection instead. This worked, but I wanted to get the USBasp programmer working, so I downloaded a few other free Windows AVR programs.
I downloaded WinAVR which is compatible with the USBasp, but it kept crashing and locking up on my Vista laptop. So I downloaded eXtremeBurner-AVR which ran fine, but it didn't have the ATmega328 in it's list of parts it was compatible with. At this point I gave up on finding a Windows compatible AVR program that worked with the USBasp and rebooted my laptop and started up my Ubuntu 11.04 Linux distribution.
I loaded AVRdude and started searching for tutorials on how to load the Arduino bootloader into blank parts with AVRdude. This wasn't too hard to find; Adafruit's LadyAda and Sparkfun all had well written tutorials to walk me through the process.
First thing I did was look in my Arduino IDE directory for the \arduino-0022\hardware\arduino\boards.txt file. This text file told me that for an Arduino Uno with an ATmega328 I needed to use the \arduino-0022\hardware\arduino\bootloaders\optiboot\optiboot_atmega328.hex bootloader file with the low fuses set to 0xFF, high fuses set to 0xDE, extended fuses set to 0x05, and the lock bits set to 0x0F. Cool, now I had all the info I needed to program the Arduino bootload into my board.
Next I needed to figure out how to use the USBasp with AVRdude. After plugging the USBasp into my laptops USB port I struggled a bit to get AVRdude to recognize that the USBasp was plugged in.
avrdude: error: could not find USB device "USBasp" with vid=0x16c0 pid=0x5dc
After Google searching for clues as to why I couldn't get it to work I found many posts stating that the Linux permissions for the USBasp required AVRdude be run by the super-user (su) or root. I tried that and still wasn't having any luck. Using the lsusb command I could see that the USBasp programmer was being recognized but it looked like there was a PID & VID ID conflict error with libusb.
ID 16c0:05dc VOTI shared ID for use with libusb
After trying to read the AVR forums for several hours to try and find a solution I remembered that some of my USB flash drives wouldn't work with Ubuntu when plugged directly into my laptop's USB ports, but worked fine when plugged into a 4-1 USB hub that was plugged into my laptop. So I tried plugging the USBasp into my 4-1 USB hub and once I got the permissions setup right it worked great!!!!! (Yeah now I was cooking!)
I loaded up the command shell and moved to the folder that had the optiboot_atmega328.hex file in it and typed in the following command into AVRdude:
avrdude -b 19200 -c usbasp -p m328p -F -v -e -U flash:w:optiboot_atmega328.hex -U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m -U lock:w:0x0F:m
- "avrdude" runs the program
- "-b 19200" is the baud rate avrdude sends the data to the programmer
- "-p m328p -F" sets the device to ATmega328p... the -F kills the warning i kept getting because I had a ATmega328 - no "F", but AVRdude doesn't have a non-F part in it's list of supported devices.
- "-v -e" erase and verify the Flash of the part
- "-U flash:w:optiboot_atmega328.hex" is the file we want to load into the device
- "-U efuse:w:0x05:m -U hfuse:w:0xD6:m -U lfuse:w:0xFF:m -U lock:w:0x0F:m" sets all the fuse and lock bits. These bits configure the devices boot, xtal and configuration settings
A complete text file of the output is available here for download.
Now that I had the Arduino Uno bootloader loaded into the micro I loaded up the Arduino IDE and wrote a small sketch to display a message on the Parallax Serial LCD.
The one quirk with this Arduino clone implementation is I have to press and release the reset button at just the right time when downloading a sketch. As soon as the "Binary sketchsize......" message shows up I quickly press and release the reset button and 8 out of 10 times I can successfully download the sketch into my board. It is a timing thing, the Ardunio IDE only waits so long to receive confirmation from the bootloader running on the micro before it errors out on the IDE. If it fails to download it is no big deal I just try again and press and release the reset button. I have gotten pretty good and timing it just right.
Also Thank You Dangerous Prototypes for putting on the contest! It was a lot of fun seeing all the cool project ideas.
I love Altoids cans too! Nice convienient shielded enclosures.
ReplyDeleteThanks to give me these type of information
ReplyDeleteHey I ended up here as I am impressed with the protostack but want to do it as a arduino clone and not mess with the AVR stuff. Could I just put in a chip with the boot-loader already installed and wire up a 6 pin header and use a FTDI cable?
ReplyDeletehttps://saglamproxy.com
ReplyDeletemetin2 proxy
proxy satın al
knight online proxy
mobil proxy satın al
İWTEY