AVR is a micro-controller suitable for (potentially) emulating actual laserdisc players so that original arcade hardware can run with an AVR instead of an old, obsolete laserdisc player.
The STK600 is a "starter kit" designed to help newbies ease into the world of digital electronics and AVR microcontrollers. Unfortunately, the documentation SUCKS. So I am going to list the steps I had to do to get my STK600 up and running.
- Download WinAVR and AVRStudio 4 (I guess 5 just came out but I'm still on 4). Read some tutorials on how to write a hello world program in a simulator to get your feet wet. This is beyond the scope of this article.
- AVRStudio came with a USB driver called Jungo. The one that comes with it won't work correctly on Windows 7 x64 (nor on x32 and must be uninstalled before you can establish any communication with the STK600) but there is a beta version, v10.2, which you can get from here: http://www.atmel.no/beta_ware/ . Probably any version after v10.2 should fix the issue.
- From within AVRStudio, go to Help->AVR Tools Users Guide. You will find the sparse documentation for the STK600 listed in here. Follow its instructions on mounting the AVR2560 board that comes with the STK600. Also follow its instructions in the Quick Start Guide about how to install the 6-pin cable for ISP programming.
- Plug in your STK600 to the USB port of your PC, turn on the STK600, and launch AVRStudio.
- From within AVRStudio, go to Tools->Program AVR->Connect
- For platform, choose STK600, and for port, choose USB.
- Click 'Connect'
- It should prompt you to update your firmware and this should be safe to do (but you may want to hold off until you get other things working). I updated and it worked.
- On the 'Main' tab, in the Device and Signature Bytes section, choose the "ATmega2560" as your device, in some cases the ATmega2560 will not be listed. It must be listed before you can advance. Check to see if you have installed all the service packs for Studio 4. That's the one that comes with the STK600.
- Go to the HW Settings tab. The VTarget will be set to 0.0V which means no power will be flowing to the AVR2560. Move the slider over to 5.0V, then click the 'Write' button inside the Voltages section to apply the change. You should see a new green LED light up on the far side of the STK600.
- Go back to the Main tab, and set your programming mode to "ISP mode". Click Settings and change the ISP Frequency to 100 kHz for now. Click the 'Write' button to apply the changes.
- You should now be able to click 'Erase Device' and have it work. Don't worry, this does not do any harm because you can reprogram the device at any time.
Now comes the part that is hard to find documentation on, and that is setting up the clock. The AVR2560 comes configured to use its crappy internal 1MHz clock which is inaccurate. If you want to see how inaccurate it is, follow this tutorial http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=50106 . The tutorial will show you how to set up a 1 second timer, but when using the AVR2560's internal clock, the resulting timer will be off quite a bit. The STK600 does provide a more accurate external clock, but finding information about how to enable this is actually pretty difficult, at least for me. I had to search a bunch of forum posts and piece the information within them all together. So here we go:
- Go to the 'HW Settings' tab and set the Clock Generator to some sensible value, anywhere between 1 and 16 MHz. (the AVR2560 isn't designed to work on a clock faster than 16 MHz). Click 'Write' to apply the changes.
- Although you have set this clock, it won't actually have any effect yet. Going back to the STK600 documentation found within AVR Studio, you may want to read section 4.8 about Clock Settings. You will see that there there is a little switch on the STK600 that you need to change. For our purposes, we want to use the STK600's clock, so you need to change the switch to "EXT" instead of "XTAL" where it defaults.
- You'd think this would be all you'd have to do, but, incredibly, there's more. From within the STK600 dialog in AVRStudio again, click on the 'Fuses' dialog. You'll see a bunch of schlop here that won't make any sense. This section represents internal configuration for the AVR2560 that can be changed/programmed within AVRStudio (which is actually pretty cool). But it is lousy that I don't have step by step instructions included with the STK600 telling me about this! But anyway.. go to the next step once you've clicked on the Fuses tab.
- CKDIV8 will most likely be checked. Uncheck this to get the clock to perform at a normal speed, instead of being divided by 8 internally.
- Now go to SUT_CKSEL where it will likely be set to use the Internal RC Oscillator. I changed this to "Ext. Clock; Start-up time: 6 CK + 65ms". From the AVR2560 datasheet, Main purpose of the delay is to keep the AVR in reset until it is supplied with minimum Vcc. The delay will not monitor the actual voltage and it will be required to select a delay longer than the Vcc rise time (see section 9.3.2, page 42, link below). I choose the longest delay in startup time just to be conservative.
- Now double-check that you've made the correct changes before clicking the 'Program' button because if you mess up, you could temporarily "brick" your AVR2560 from what I understand. I say temporarily because there are apparently ways to fix this. Fortunately I did not have to go down this path.
- Once you've verified your settings, click 'Program' and your AVR2560 should now be using the clock source supplied by the STK600. Now you can go to the HW SEttings tab and adjust the clock in real-time which is what you obviously wanted to do in the first place when you bought the STK600 right? :)
For those curious, you can download documentation about the AVR2560 ( http://www.atmel.com/dyn/resources/prod_documents/doc2549.pdf ) and read about the fuses. By default, the clock source is an internal RC Oscillator running at 8 MHz which is then divided by 8 to get an approximate 1 MHz source. See page 337 of that PDF I linked.
The STK600 documentation once again assumes that its users are previously experienced with AVR microcontrollers which makes no sense since it is supposed to be a "starter kit". The STK600 documentation says: To use the RS232 interface, the AVR's UART pins must be connected to the appropriate pins on the "RS232 SPARE" pin header. Use a 2-wire cable to connect the AVR's RXD and TXD pins to the pin header. The "RS232 SPARE" pin header is found in the target header section, while the DSUB marked "RS232" is located on the other end of the card.
As a newbie, it is difficult to separate the STK600 and the AVR2560 and the documentation does not do a good enough job making this separation apparent.
The first time I read this, my eyes glazed over when I read "AVR's UART pins". Since the AVR2560 is included with the STK600, the least the documentation should do is tell you what those pins are for the AVR2560. Well, after pulling out more hair in frustration, searching some forum posts, and reading the AVR2560's datasheet, I discovered that the UART pins for the 2560 are port E, pins 0 and 1 (for the first UART, which is USART0). Go to section 12.3.5 of the AVR2560's datasheet and you'll see that Pin0 of PortE (PE0) is USART0's receive pin, while PE1 is USART0's transmit pin.