Getting started (A cheap introduction to AVR)
This is an account of the steps and processes I took to start working with the AT90s2313. This guide is based on the Futurlec AT90s2313 Development board ( http://www.futurlec.com/ATDevBoard.shtml or for Australians http://www.futurlec.com.au/ATDevBoard.jsp )
This provides just one way of starting with AVRs, there are others. I have found this method to be a good trade-off between start-up cost and ease of use. Cheaper would be to build your own programmer straight off but this is a very dfficult task when you aren't familiar with AVRs and wouldn't be as good value considering the extras the Futurlec board includes. Easier would be to buy the official Development kits, STK500, STK501 etc but this initial start-up cost is not usually justifiable for a hobby, maybe if you are setting up a lab or doing this for your job.
Anyway I've recently taken the trip from programming PCs to AVRs. So I'll detail a little of how I did it nice and cheaply.
The end goal which, I now have acheived, is to have an AVR connected to my PC, be able to pull up some software, write a program in C, program it into the AVR, have the AVR execute the code and do something.
Being in Australia I'm used to having to mail order most of my electronics. I have found a really, really cheap supplier in Thailand (don't worry the head office is in Australia and the website is in English). They are www.futurlec.com or www.futurlec.com.au (similar sites but the .com gets updated more often).
Futurlec don't have any minimum orders like Digi-Key etc and they also make their own development boards which are very cheap. I bought their AVR 2313 Development board ( http://www.futurlec.com/ATDevBoard.shtml ) it costs US$19.90. It comes fully assembled. It is such great value. The raw components alone would cost three times as much as the made up board.
The Futurlec board is pre-assembled, great value and very capable. Did I mention great value? oh yeah :)
It does come with a CD with example asm programs and programming software for Windows and DOS and a small manual for using the board. The manual is pretty sparse though.
At the same time you should buy at least:
|Futurlec part #|
|1||20 Pin IDC socket||IDCC20|
|2||1 metre of 20 core multi-coloured cable||MCCABLE20|
|1||3 Pin polarized header||POLHDCON3|
|2||4 Pin polarized header||POLHDCON4|
|2||10 Pack of pins for above headers||PLHDPIN|
If you want to use a 16x2 LCD with this board I recommend buying the prewired version for US$12 ( DEVLCD ) as people have had problems with the documentation and trying to wire up your own (I wasted a whole day with this problem - then just ordered the prewired one)
Optional: Pre-Wired 16x2 LCD (Part Number: DEVLCD)
NOTE: When using the LCD, make sure you disconnect it when attempting to program the AT90s2313. Otherwise the download program will report an error and will not successfully update the code.
Also you'll need some way of connecting the board to the serial port of your PC. I'm using a pre-wired 9-pin serial to 3.5mm Stereo plug cable I had from using PICAXEs (I've included a diagram of how it is wired).
Assuming you need to build your own cable that goes directly from the PC's serial port and the Futurlec development board and are connecting to a modern PC (ie not Mac, they use a different plug) then you'll need to buy the following:
(assuming all of the above are purchased as well, you will just need either: )
9-pin D-SUB female (DSUBPCSF9)
9-pin D-SUB female (Part Number: DSUBPCSF9)
D-Sub 9 Contact Female IDC Ribbon Conn (Part Number: DSUBIDCF9 )
I suggest the second option, the "D-Sub 9 Contact Female IDC Ribbon Conn", if you don't want to solder the connections but crimp the serial plug onto multicore cable ( DSUBIDCF9 ) --- (I recommend this together with your 20 core multi-colour cable cut down to 9 wires, a lot easier). At the other end you just crimp the correct three of the 4 Pins of the RS-232 header. To find out which three, use your multimeter and the above diagram to test for continuity.
That should be it for hardware, that will cost in the order of US$35-US$40 I think, I might be off as I haven't done a proper costing. This will allow you to program the AT90s2313 using a tested (ie "known good") programmer, read and write up to 32Kbytes of data to the 24LC256 chip (I will post C code on the site to do this in the next day or so). Set and read the current time and date from the DS1307 (with battery backup this chip holds the time for 10 years). Send and receive serial communications to/from a PC or any other RS-232 device. And generally connect the AT90s2313 to anything you want to. I just completed a C program that reads the temperature from a DS1631 (note there is no slot on the board for the DS1631 so I connected it via the I2C port the board provides).
For software you will need to download the AVR Freaks distribution of WINAVR . This includes a basic IDE (Programers Notepad) and the actual avr-gcc compiler. Don't forget to read the guide for installing and configuring WinAVR too. You will also need to download the AVR studio program from Atmel (I installed the 3.5 installer version available on the WINAVR page, installed it (so it set up the paths correctly) then went and installed AVR studio version 4 (they don't conflict at all). I now use version 4 exclusively.
You will also need to download and install the Proycon AVRlib to compile my example programs that use it this library of great functions ( http://hubbard.engr.scu.edu/embedded/avr/avrlib/ ). Again just follow it's installation instructions.
And then there is one last thing. To have one click programming (sending the code to the chip) of the Futurlec board, you need to update the avrdude.conf file and add an option in Programmer's Notepad to invoke avrdude. Avrdude is a program that allows you to send your code to your chip. I've included the avrdude.conf file needed. Just overwrite the original with it (eg c:\WINAvr\bin ).
(Right-Click and select "Save target as..." or similar )
To add the option to Programmer's Notepad, go to Tools > Options > Tools (on the left) > Add . Then fill out the boxes similar to the images below.
Obviously if you have questions, feel free to post in the forum.
Also, you can go and download the software, run some simulations, step through code etc without spending a cent/pence/pfennig. Setting up the software is probably the hardest part so it might be a good idea to set it up before ordering anything and make sure you are comfortable with it.
ERRATA: If you use Windows2000 or WindowsXP (anything using the NT Kernel) then by default you will not have direct access to your printer port. Since the 2313 board is programmed via the printer port (LPT1) then you need to provide low level access to them. There are several small programs available to do this. On the CD Futurlec provide yu will find a file UserPort.zip . Unzip this file and intsall it via the instructions in the included PDF file. If you want to use a different program then look at "giveio.sys" or google for "direct printer port access" etc. Note you only ever need to run these programs once, after that you will continue to have direct access.
Pros and Cons
One drawback of doing it this way is that most beginner's resources on the internet assume you have an STK500 which are great and all but rather expensive to start with, considering you also need the STK501 (priced the same at about US$100, so US$200 in all) to then program all the AVR chips. At least this way you can get familiar with the 2313 and AVRs in general and then build your own programmer, or buy one, when you want to program other chips.
Also note the AT90s2313 is soon to be replaced by the AVRTiny2313. As far as I have seen, they are the same externally and the new Tiny2313 is twice as fast. They are pin compatible so hopefully the Tiny2313 can be programmed by the 2313 Dev board.
I have found this method to be a good trade-off between start-up cost and ease of use. Cheaper would be to build your own programmer straight off but this is a very dfficult task when you aren't familiar with AVRs and wouldn't be as good value considering the extras the Futurlec board includes. Easier would be to buy the official Development kits, STK500, STK501 etc but this initial start-up cost is not usually justifiable for a hobby, maybe if you are setting up a lab or doing this for your job.
I hope this helps everyone who is seeking help in the area. If you have any comments, criticisms, suggestions, etc please either post them in the forums or if you feel the need, email me.
Have fun and enjoy the mighty AVR with the great AVR-GCC free compiler.