Updated 25 April 2009
With this notes I’ll show how I configured an Atmel STK500 as an Arduino-based development system.
I used the STK500 instead of a real Arduino PCB because I already had it and the board carries 8 switches, 8 LEDs and a variable, software programmable AREF voltage as well as a variable power supply. Great things to experiment with on a single board.
What follows applies to the STK500 evb equipped with an ATMega168. Please note I made my best to be as accurate as possible, some errors may be present though. Should you find some, please let me know.
AVR Studio 4.14 build 589 is used in the following; newer versions should be hopefully upward compatible.
Things needed :
One Atmel STK500 Evaluation Board with power supply
One Atmel ATMega168
One 16MHz crystal
One serial cable
One PC with AVR Studio 4 and one serial port
The Arduino software development system and the bootloader file for the ATMega168.
In case the PC doesn’t have a serial port but just USBs, a USB to serial adapter is necessary to interface the STK500 to the PC. I haven’t tried but it should work.
RS232 is needed in first instance to interface the STK500 evaluation board with the PC.
First the STK500 was wired and the jumper set as shown in the picture below.Click the picture for a larger version.
The ATMega168 must be on board, any other CPU must be removed.
The ATMega168 must be placed in the green 28pin socket and the 16MHz crystal into the socket as shown. The PC must be connected to the STK500 serial programmin port, the one labelled “RS232 CTRL” on the PCB. Take note what port of the PC you are using (say COM1 or COM2).
Launch AVR Studio and turn on the STK500.
From AVR Studio select “connect” (the “IC” icon below the menus) and select “STK500″ as platform and “COM1″ or “COM2″ ( the one connected before ) as port.
Press “connect” and the following should come up, the “main” tab :
Select ATmega168 for “device and signature bytes” then press the “Read Signature” button and check that the platform recognizes the device (the “Signature matches selected device” label is what you want to see ).
Press the “Erase device” button.
Next, press the “program” tab to display the following:
Check the “Erase device before FLASH programming” and “Verify device after programming”.
Now select the “…” button to the right of the “input HEX file” field and browse to the directory “\arduino-0012\hardware\bootloaders\atmega168″ starting from the place where you exploded the Arduino zip file you downloaded and select the ATmegaBOOT_168_ng.HEX file. Otherwise browse to where you saved the bootloader downloaded from arduino.cc
Press the “Program” button : after a few seconds the bootloader will be FLASHed into the micro and verified automatically. The bottom part of the window shall give some promising “OK !”s
Now click on the “Fuses” tab. Make it look like the following picture: make sure to un-check CKDIV8 and to select the “Ext Crystal Osc. 8.0 – MHz…”.
Changes are reflected in the “EXTENDED”, “HIGH” and “LOW” registers at the bottom: make sure they are the same as below.
Press “Program”.
Now, with the “lock bits” tab, the bootloader must be protected from overwriting :
The “BLB1″ must be changed to what is above and the “LOCKBIT” register should finally be 0xCF as above, press “Program”.
Now you’re done: you can remove the 6-pin ribbon cable necessary to program the micro and move the serial cable to the other serial port connector of the STK500 (the one marked “RS232 SPARE” on the PCB), make sure you leave connected the PD0 and PD1 to RXD and TXD because these pins make the serial port of Arduino !
Now you have and STK500 running Arduino with the added advantage of pushbuttons and LEDs on board plus variable power supply (useful when working with 3.3V external sensors) and variable Analog Reference (AREF).
The AREF short pin must be inserted when the on-board voltage reference is to be used. Remove the short otherwise. The Analog Reference Voltage can be controlled with the “Connect” dialog box. Target Supply voltage can be controlled there also.
The connections of teh ATMega168 are available at connectors J700 & J701 of the STK500.
The pinout is shown below along with the equivalent name to Arduino’s.
Again, the “spare serial port” of the STK500 is the one used to download sketches on the STK500-Arduino: remember to move the serial cable to this port to connect your PC to your Arduino !
The Reset button on the STK500 is now the reset button of the STK500-Arduino: it must be pressed to download sketches on the board as you would with a regular Arduino.
Connecting PB5 to an LED of the ones on the board gives a visual monitor where the LED blinks right after reset to show it is waiting for the code on the serial port.
Update : there’s a bug in AVR studio 4.16 which prevents bootloader from being written correctly into the micro, see comment below from avirdi.
Have fun and write for questions and comments.
Alessandro




m
m
m
19 responses so far ↓
quispqix (Curtis) // Jul 1, 2008 at 10:49 am
I got some crystals today and I’m eager to test this.
bjr // Jul 1, 2008 at 4:56 pm
I have tried following the instrunctions for “Programming the Arduino firmware to a ATmega168 with the STK-500 in High-voltage mode”, but I cannot program the device using the AVR-ISP mkII programmer, or via the serial cable. I have followed the instructions to connect all jumpers correctly, but when I connect the AVR-ISP mkII to the ISP6PIN or SPROG2, it says “The ISP connector appears to have been connected the wrong way, or the reset line may have an incorrect pull-up”
When I try programming using teh serial RS232 cable, it says the programming speed specified on the “Board” page may be incorrect.
Any help, please?
Thanks
admin // Jul 2, 2008 at 10:03 am
bjr, I don’t have your programmer but I suspect you should check the connections to circuit around the pins shared with the programmer. The reset pin as suggested by the error message is a good candidate : too strong a pull up and the programmer won’t have control on it.
Try programming the chip off-system : if it works, your procedure is fine while the circyuit is not.
Hope this helped.
bjr // Jul 3, 2008 at 11:16 am
admin, Thank you for your response. You said that you don’t have my programmer (AVR-ISP mkII) – how have you programmed the chip?
I’m not sure what you mean by “Try programming the chip off-system”. Could you eplain that a little more to me?
As I said in my original posting, I have tried programming the chip with the RS232 cable, but get an error related to programming speed.
Thanks again for your reply.
admin // Jul 3, 2008 at 4:29 pm
bjr, I programmed the chip with the STK500 with the chip on one (the right one !) of the sockets and wired the board as on the first picture above. I did not use High voltage mode. AVR-ISP mkII is an ISP programmer, it does not use high voltage mode.
With Off-board I mean the chip with the minimum hardware connected (crystal, weak pull-up on reset and power supply) on say, a breadboard, and your programmer connected to the pins of the chip.
Electronics-Lab.com Blog » Blog Archive » The Atmel STK500 EVB as an Arduino development board // Oct 24, 2008 at 6:51 pm
[...] Atmel STK500 EVB as an Arduino development board – [Link] Tags: Arduino, ATMEL, Atmel STK500, Development, STK500 Filed in Arduino | 2 [...]
News for Geek » STK500 as an Arduino // Mar 9, 2009 at 6:13 am
[...] have embraced the Arduino. [Alessandro] has decided to bring the two together so that you can use the Arduino environment with the STK500. Unlike the Arduino, it comes with 8 LEDs, 8 switches, a variable power supply, and variable analog [...]
STK500 as an Arduino - Hack a Day // Mar 17, 2009 at 12:47 am
[...] have embraced the Arduino. [Alessandro] has decided to bring the two together so that you can use the Arduino environment with the STK500. Unlike the Arduino, it comes with 8 LEDs, 8 switches, a variable power supply, and variable analog [...]
avirdi // Apr 17, 2009 at 4:00 pm
Excellent work!!!
I burned the bootloader to SKT500, removed the 6-pin ribbon, selected COM1 (port) and Diecimila (board) in arduino IDE. But I am getting this error when I try to upload an example program to the board:
avrdude: stk500_getsync(): not in sync: resp=0×00
avrdude: stk500_disable(): protocol error, expect=0×14, resp=0×51
Do we need to keep the reset button pressed all the while when the arduino IDE is uploading the program or just once befor uploading the program?
Please help!!!
Thank You.
admin // Apr 18, 2009 at 10:53 am
Of course you followed all the steps and configured the fuses and lock bits of the ATmega168. You connected the serial port to the “spare” port of the STK500, configured Arduino dev software to connect to the right port ?
The reset button must be pressed once then released I’m not sure moments before or after selecting “download to target” from the menu. Try both cases.
Are you sure You deselected the “div 8″ tick box in the fuses window ? I happened to go nuts before realizing I forgot to do it.
Check every step and you should be OK.
Repeat the programming steps one by one.
Let me know.
Ciao
avirdi // Apr 18, 2009 at 10:20 pm
Alessandro,
I am still getting the same error. I followed the steps exactly as described. Two things I suspect:
(1) Could it be because I am using a USB to serial adapter? (but it is working with AVR Studio and WinAVR)
– In this case, I will try using another computer with a serial port.
(2) Or because I upgraded my STK500 firmware to 2.0A (from 1.0E)?
– If arduino’s avrdude is having problems with “stk500″ because of firmware upgrade, Can I compile programs using Arduino IDE and push the resulting .hex file using avrdude command line with “sktv2″ option? In that case, what will the command look like?
Thank you,
avirdi
admin // Apr 25, 2009 at 8:58 am
Ciao A., sorry for not replying sooner but I’ve been pretty busy during the last ten days.
To make sure I didn’t miss anything in my description I followed the steps as descripted one by one and apparently everything is fine.
I also downloaded the blinking LED example sketch ( http://www.arduino.cc/en/Tutorial/BlinkingLED ) and it compiled and downloaded to the board and the LED blinks just fine.
You say that with the serial port straight out of the PC it doesn’t work either so it is not the USB to serial converter. I checked the firmware version of my stk500 and it is as follows:
HW 02, FW 02, minor fw 0A (from the bottom of the “info” window of the STK interface of AVR studio.
I’d not go with commands straight from AVRdude as it should work through the STK in first instance.
In the Arduino interface did you select from the “tools” menu the right board (Arduino NG or older w/ATmega168 ) and correct serial port number?
Try connecting PB0 to and LED of the STK500 : when you press reset and the board waits for the data, the LED should blink two or three times then stay on until the sketch has been loaded. If it does your chip is programmed fine with the bootloader so you should concentrate on the Arduino to STK interface. PD0 and PD1 connected on the STK to RXD and TXD RS232 SPARE, the serial cable connected to the RS232 SPARE DB9 connector and PB5 connected to and LED as a wait for download flag. Is the 16MHz quartz in place ?
Please return on this when everything works (or earlier, in case).
Ciao
Alessandro
avirdi // Apr 25, 2009 at 10:59 am
Alessandro,
Thanks for your reply. your instructions are perfect. I figured out the problem: It is a bug in the AVRStudio’s version 4.16build 628. The bug passes the verification process without actually flashing bootloader onto a blank uC.
The patch for this bug can be downloaded from:
http://www.atmel.no/beta_ware/BootProgHotFix.exe
My STK500 is now working fine and I am using an ATmega328 on STK500 (by choosing “Arduino Duemilanove w/ ATmega328″ as the board in Arduino IDE)
I found this out in a discussion on AVRfreaks (http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=75568&start=0&postdays=0&postorder=asc&highlight)
You can update your instructions to include this. Thank you again for sharing knowledge.
Virdi
admin // Apr 25, 2009 at 1:10 pm
Virdi, thank you for your update.
Best
A.
Nicholas // May 6, 2009 at 9:42 am
how ill the whole setup look like? the arduino will be powered by USB or ICSP?
Nicholas // May 6, 2009 at 10:03 am
“Now you’re done: you can remove the 6-pin ribbon cable necessary to program the micro and move the serial cable to the other serial port connector of the STK500″
its said that only one serial adapter is required, if i move my serial adapter from RS232 CTRL to RS232 SPARE, i cannot programmed from my AVR Studio anymore. Some advice? Thanks.
admin // May 6, 2009 at 10:40 am
@Nicholas, the board will be powered by the STK500 wall adapter. The STK500 needs to be connected to the RS232 CTRL port only once when downloading the Arduino bootloader to the board. When done, you will never need the RSRctrl port any more. The 6-pin ICSP connector can be removed for good as well.
On the other hand sketch downloading is accomplished through the RS232 SPARE port as many times as needed to develop/download/debug the sketch.
If the PC is needed for some runtime input/out from/to Arduino (that is when using the serial port communication in your sketch) the communication port will be the “RS232 Spare”. Otherwise the STK500/Arduino can run as a standalone platform.
Hope this helps
A.
Brio // Jul 22, 2009 at 5:16 am
Is there a way to set the serial transmission blinking signal (currently assigned to PB5) to a different pin?
Thanks
admin // Jul 22, 2009 at 8:29 am
@Brio, PB5 is assigned by the developers of Arduino but I think the source code is open source so you could change the assignment and recompile the boot file. My suggestion is to try to let PB5 alone and try to use a different pin for your application though.
Best regards
Alessandro
Leave a Comment