Setting up the STK500


Unpack the STK500 and lay the components out on a table in front of you. The components you will require for  project 1 are three of the two wire jumpers, the 6 wire jumper, the serial interface cable, the board itself, an Atmega16 microcontroller, and the power supply.


 


Figure 6.1

If you notice, the serial adapter in my setup has been replaced by a serial to USB adapter. I could not use the serial to serial connector as my laptop that I use to program does not have a serial connection. If you encounter a similar problem, you can pick up an adapter from Radio Shack or order one on line. The one I use is from Radio Shack and functions well. I have had no problems other than the connection being a little slower than with the serial to serial connection I use with my desktop computer.




Figure 6.2


Also, you can see the Atmega16 inserted in the STK500. Make sure you consult the manual which came with the STK500 to insert your chip in the correct slot and with the correct orientation (plugging it in backwards has not fried any of my chips, yet, but it is not a good idea to try). The particular Atmega16 I am using is a 5 volt version. I have not tested a 3 volt version with the STK500, but the Atmega16L, the 3 volt version, is rated to accept up to 5.5 volts, so there shouldn't be any problem. In fact, it would be best to use the L version since our product will rely on battery power.


The jumpers you need to have installed on your STK500 board are the VTARGET and RESET. The location of these jumpers is in figure 6.3.




Figure 6.3


Next you will need to install the jumper wires so you can interact with the microcontroller and it can light up some LEDs to interact with you. Jumper wires are arranged as follows:


Figure 6.4




Figure 6.5


As you can see from the table in figure 6.4, the port names and switch names all start with 0 instead of 1. Your switches and LEDs are numbered 0 through 7, for a total of 8 of each, the same number of pins available on each port of your microcontroller.


You need to set up your board to receive the program to send to the microcontroller. Install the 6 wire jumper, 9 volt power supply, and connect the serial interface from the board to your computer. The serial interface goes to the port marked RS232 CTRL on the STK500. The other port labeled RS232 SPARE is for sending serial messages to your computer or other device from the microcontroller.




Figure 6.6


The 6 wire jumper is connected to the first pink PROG1 6 pin header for the Atmega 16 microcontroller. Consult the STK500 user manual to determine which PROG header to use if you are using a microcontroller other than the Atmega 16.







Figure 6.7


Now, just slide the power switch and your board is ready to receive a program.


Open the project we wrote earlier in BASCOM. As a rule of thumb, I always recompile the program prior to loading it on the board in case I made any changes and forgot to recompile. It is not necessary, but it can save some headache.




Figure 6.8


On the tool bar, click the programmer icon followed by Programmer as shown in figure 6.8 and, if you set the STK500 board as your programmer, have it correctly connected to your computer's serial (or USB in my case) port, have the microcontroller inserted properly and your jumpers correctly installed, it will begin downloading your program on the chip. You will see a brief screen displaying the progress of the transfer similar to the one shown in figure 6.9. The screen is not up very long, but you should be able to make out a percentage progress of the programming and verification. If the screen flashes too quickly to make out anything at all, that means BASCOM failed to recognize the programmer or the chip for some reason. Time to start troubleshooting. Check your COM Port settings.




Figure 6.9


The progress window will close out automatically and you should be ready to test your program on the board immediately. Try pressing switch 0. LED0 should illuminate for 1.5 seconds then turn off. If you press switch 1, LED0 will illuminate and 1.5 seconds later LED1 will illuminate. 1.5 seconds later, both will turn off. Switch 3 makes the first turn on for 1.5 seconds then turn off before the second LED does the same. Switch 4 just makes the second LED turn on for 1.5 seconds before turning off.


If the program was correctly written and your jumpers correctly installed, you should get these results. Congratulations! You just completed writing and testing your first embedded software code.

STK500 and Project 1