Difference between revisions of "AVR Drivers"

Jump to navigation Jump to search
2,384 bytes added ,  17:33, 1 May 2011
info on compiling the code in AVR Studio 5
(info on compiling the code in AVR Studio 5)
Line 20: Line 20:




[[File:Soic8clip.jpg|thumb|200px|SOIC 8 clip with wires rearranged]]The other piece of hardware is a SOIC 8 clip to attach to the pins of the Atmel chip on the flashlight driver. There are cheap ones on eBay that have been problematic, but will generally work. They cost about $12 as well. It is best to get one with a ribbon cable that attaches to pins coming out of the clip. The individual wires of the ribbon cable can be moved to the correct pins for the ISP programmer. See below for the proper configuration.
[[File:Soic8clip.jpg|thumb|200px|SOIC 8 clip with wires rearranged]]The other piece of hardware is a SOIC 8 clip to attach to the pins of the Atmel chip on the flashlight driver. There are cheap blue ones on eBay that have been very problematic, but sometimes work. They cost about $12. It is best to get one with a ribbon cable that attaches to pins coming out of the clip. The individual wires of the ribbon cable can be moved to the correct pins for the ISP programmer. See below for the proper configuration. There are [http://cgi.ebay.com/SOIC-8-SOIC8-8-Way-SMD-Programming-Testing-Test-Clip-/380333853764?pt=LH_DefaultDomain_0&hash=item588daa0c44 more expensive ones on eBay] as well that might work better. These are black, cost about $21, and don't seem to include the cable. The programmer itself includes a cable but you will need some way of connecting the wires in the ribbon cable to the pins sticking out of the clip.


===Software===
===Software===
Line 26: Line 26:
You need some kind of software to interface with the USB programmer and read or load programs into the Atmel chip.
You need some kind of software to interface with the USB programmer and read or load programs into the Atmel chip.


You will at least need AVRDUDE (AVR Downloader UploaDEr) to upload and download files to the Atmel chip. It is a command line interface (DOS). If you use Tido's programs then you don't need to compile anything: those programs are ready to be loaded.
You will at least need AVRDUDE (AVR Downloader UploaDEr) to upload and download files to the Atmel chip. It is a command line interface (DOS). If you use Tido's programs then you don't need to compile anything: those programs are ready to be loaded. If you install WinAVR, AVRDUDE will be included. You can also install AVRDUDE separately.


If you want to customize the programs or write your own, you will need a compiler. The programs can be written in assembly language or C. Assembly can give more compact programs, but C is easier to write and understand, so that is what is being used so far. AVR Studio is available free from Atmel after registering to allow you to write and compile programs and load them. It has a neat interface for some programmers, but not USBasp, so if you are using USBasp, you will still need AVRDUDE to actually upload the files.
You may also need to install a driver for the USBasp.


[http://winavr.sourceforge.net/ WinAVR] is a free collection of all the software you need as well as a graphical user interface (GUI) to edit, compile, and load programs. [http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/heliosr Eclipse] is another free GUI and is what Tido uses. It requires a plug-in that allows it to work with the installation of WinAVR.
If you want to customize Tido's programs you will need a C compiler configured to work with AVR equipment. (Some people write AVR programs in assembly language which gives more compact programs, but you are on your own if you go that route.) You have two options: WinAVR or AVR Studio.
 
'''AVR Studio''' -  AVR Studio is available free from Atmel after registering to allow you to write and compile programs and load them. It has a neat interface for some programming boards, but not USBasp, so if you are using USBasp, you will still need AVRDUDE to actually upload the files. The latest version is a beta called AVR Studio 5 which runs on Windows and uses Microsoft Visual Studio.
 
'''WinAVR''' - [http://winavr.sourceforge.net/ WinAVR] is a free collection of all the software you need as well as a graphical user interface (GUI) to edit, compile, and load programs. [http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/heliosr Eclipse] is another free GUI that goes on top of WinAVR and is what Tido uses. It requires a plug-in that allows it to work with the installation of WinAVR. Follow instructions [http://interactive-matter.eu/how-to/developing-software-for-the-atmel-avr-with-avr-eclipse-avr-gcc-avrdude/ here] for installing WinAVR and Eclipse. Eclipse is optional. Then configure Eclipse for AVR. There is also a [http://avr-eclipse.sourceforge.net/wiki/index.php/The_AVR_Eclipse_Plugin Wiki] about Eclipse AVR.


===BLF-VLD===
===BLF-VLD===
Line 44: Line 48:
'''Programmable''' allows you to assign any of the extended modes to your 3 simple modes.
'''Programmable''' allows you to assign any of the extended modes to your 3 simple modes.


This archive also has a very good README file in the "docs" folder which explains about the code and the three different configurations.
The BLF-VLD archive also has a very good README file in the "docs" folder which explains about the code and the three different configurations.


==Getting Ready==
==Getting Ready==
===Installing software===
Installing software on your PC and setting it up to get the USB programmer working. Put files in the correct locations so you can access them.
Follow instructions [http://interactive-matter.eu/how-to/developing-software-for-the-atmel-avr-with-avr-eclipse-avr-gcc-avrdude/ here] for installing WinAVR and Eclipse. Eclipse is optional. Then configure Eclipse for AVR. There is also a [http://avr-eclipse.sourceforge.net/wiki/index.php/The_AVR_Eclipse_Plugin Wiki] about Eclipse AVR.


===Set up your clip===
===Set up your clip===
Match the pins of the Atmel chip with the pins of the USB programmer. Only pins 1, 4, 5, 6, and 7 of the Atmel are used by the ISP programmer.
Match the pins of the Atmel chip with the pins of the USB programmer. Only pins 1, 4, 5, 6, and 7 of the Atmel are used by the ISP programmer (maybe pin 8 VCC is used).


The pins of the ATMEL chip are
The pins of the ATMEL chip are
Line 152: Line 151:
If you use the standard BLF-VLD files, you don't need to compile anything. But if you write your own code or modify the BLF-VLD files, you will need to compile your own files. By doing this you can have different numbers of modes, different brightness levels, turn off the memory function so that the light always comes on in the same mode, etc.
If you use the standard BLF-VLD files, you don't need to compile anything. But if you write your own code or modify the BLF-VLD files, you will need to compile your own files. By doing this you can have different numbers of modes, different brightness levels, turn off the memory function so that the light always comes on in the same mode, etc.


To customize the interface, use the file driver.c in the BLF-VLD directory. This file has code for all 3 standard configurations in one file. There is a good example of how to configure a light to 4 fixed modes with no memory [http://budgetlightforum.com/node/799?page=5#comment-33536 in this comment] to the main thread.
To customize the interface, use the file '''driver.c''' in the BLF-VLD directory. This file has code for all 3 standard configurations in one file. There is a good example of how to configure a light to 4 fixed modes with no memory [http://budgetlightforum.com/node/799?page=5#comment-33536 in this comment] to the main thread. You modify it by commenting out different lines that define functions or setting parameters, like the number of modes. There are a lot of comments in the code itself and the readme file included in BLF-VLD gives instructions.
 
If you are using AVR Studio 5, you will need to start a new project, maybe called "MyProject". Start AVR Studio 5 and go under File and New Project and give it a name (MyProject) and location (can go in BLF-VLD or its own directory on the C: drive). After you click OK, it will ask you what type of board you will program. Choose ATtiny13A. It will now generate some simple code for a blank program. Open up driver.c in a text editor, copy all of that, then go back to AVR Studio and paste it in over the simple code that was already generated for you. Go under the Project menu heading and select MyProject Properties. Where it says Generate Files, check the boxes for hex and eep. These are the files that will be transferred to the chip.
 
Line 1029 of the code declares a variable type within a "for" loop which is not allowed in the type of C that Visual AVR supports (needs support for C99). You can fix the code easily enough by changing:
 
  for(uint8_t i = 0; i < 2; ++i){
 
to:
 
  uint8_t i;
  for (i=0; i < 2; ++i){
 
Now you can compile the project. Go under the menu heading Build and choose Build MyProject. This will create the files you need in MyProject/MyProject/Debug. If you are using a programming board that AVR Studio supports (USBasp and most others are not supported), you can move the files and change fuse settings from within AVR Studio. Otherwise you should have WinAVR installed on your computer (or at least AVRDUDE) and use AVRDUDE commands to upload the files to your driver as described above.


==Other Issues==
==Other Issues==
confirmed, developer
1,668

edits

Navigation menu