Programming ATtiny85 with USBASP programmer by using cmd and AVRdude

20:48 24 Comments



Programming ATtiny85 with USBASP programmer by using cmd and AVRdude







This short tutorial will be more useful for ones who are new to programming Atmel family microchips, after this tutorial we will get some basic knowledge about using CodeVisionAVR, how to setup a project and we will also cover a little bit of C++ programming.



Before you start going throught this guide, make sure that you have got everything that is in these lists.

Necessary equipment required:

·         USBASP programmer with a cable

·         Solderless breadboard

·         Few jumper wire cables

·         200ohms resistor

·         1 Led

Programms required:

·         Some kind of programming environment where to create the code and where to compile it, for this tutorial I have chosen CodeVisionAVR.

·         AVRDUDE


Schematic view of the circuit:




Short guide on CodeVisionAVR:
I won't be discussing principles how the CodeVisionAVR works, but instead I will jump straight into creating the project solution.
The first thing to do is of course to start the program and create a new project (“File -> New -> Project”), a message box will pop up:






Nothing strange, we want to use it so click on “Yes” and let's continue, another window will pop up, giving us some of the options (Target AVR Chip Type):






We need to select the first radio button, which has some text next to it: “AT90, ATtiny, Atmega”, this is what we need for our project, so click on “OK”.
Finally we have reached Chip Settings Window: in the listbox provided next to the “Chip” label you will need to find the chip you are going to program (ATtiny85), leave other settings as they are, after that just choose an option: “Program-> Generate, Save and Exit”.







Few File Dialogs will come up, you will need to choose where to save them, and give a name to them. The best thing to do would be to create a folder and save these files in that folder:






After everything has been saved, in the main window of the left side in the Code Navigator, we have our project root with our files, on the left and the biggest part we have on the right with our code which was generated previously, now we need to clean it up, leaving some bits (tiny85 library, initialization and the loop):





Now the code can be written, the complete code is given below.


You Can Download programm CODE, HERE

After you have either rewritten or copied this code (I would highly suggest to go through it and try to understand all features involved with this code), the project is ready to be build. To build the project go to: “Project->Build All”.







If the build was successful, you shouldn't get any errors:








So click, on “OK”, and start AVRdude to program our ATtiny !
Before we actually start the AVRdude, lets prepare our workspace. The first thing is to set-up our circuit connected to USBASP programmer:




After the circuit has been set up, lets prepare some data needed for AVRdude:
Attiny85 in AVRdude is indentified as a part numer t85
Hex file location should be in : Project_Folder->Debug->Exe->hex_file_name.hex
So my full file path is: C:\cvavr\projects\ATtiny85_tutorial_1\Debug\Exe\first_project.hex
Full AVRdude command will look like this:
avrdude.exe -p t85 -c usbasp -B 4 -e -U flash:w:"C:\cvavr\projects\ATtiny85_tutorial_1\Debug\Exe\first_project.hex":i -v
As the AVRdude command is ready we need to start our Command Prompt, to start the Command Prompt type in windows search cmd, and it should find it easily.


Type command: cd \ (by that we are chaning the directory to C:\)







Type another command: cd Win (and press Tab button on the keyboard, by that it should return the full folder name WinAVR-20100110 (if the AVRdude was installed by default, otherwise you will need to find it's location), type “\” and press again Tab untill you find “bin”, the full command should look something like this: cd WinAVR-20100110\bin and at the end press “Enter”.




.

The next thing do is to copy and paste our command which we prepared before: avrdude.exe -p t85 -c usbasp -B 4 -e -U flash:w:"C:\cvavr\projects\ATtiny85_tutorial_1\Debug\Exe\first_project.hex":i -v
To paste that command line into cmd, we need to do it by Right click on the cmds area with a mouse:









So as our USBASP programmer at one end is connected to computer's USB port and at another end to our microcontroller, we are ready to do programming, so just simply press “Enter” once more and watch.
A lot of thing will be listed in the cmd screen, but at the end if everything was done correctly you should see something like that:






Also as soon as the chip has been programmed the LED should start blinking you can disconnect all the wires only leaving the VCC and GND wires to the programmer (do it only when programmer is disconnected from the USB) or instead of using programmers power source you can connect these wires to your own power source, of course the LED will only start blinking if during the process no errors were found.
But in case if there are some kind of errors, check the wiring connections between USBASP cable and microchip first, and always pay attention to what the compiler and cmd states at the end of the process.
Thank you for your attention, hopefully you enjoyed this tutorial, there will be more tutorials coming up soon, so don't forget to visit us again and share our blog with your friends !

You can Download FULL tutorial file HERE:





Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google

24 comments:

  1. greensboro electrician At Emergency Electrician Greensboro, we understand how much you rely on electrical energy to power your everyday life. Fortunately, we are experts regarding safeguarding against its inherent risks and are all ready to do the reliable labor had to make sure your home's power systems work for decades to come.

    ReplyDelete
  2. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. 15kv capacitor

    ReplyDelete
  3. Buy YouTube Comments for the best price. We provide youtube comments in more than 7 languages!
    buy youtube comments

    ReplyDelete
  4. Buy YouTube Comments for the best price. We provide youtube comments in more than 7 languages!
    yt comments

    ReplyDelete
  5. Antalya is one of the biggest and most popular cities in Turkey. It is the capital of Antalya Province and has a population of over one million people.
    antalya summer 2060

    ReplyDelete
  6. The best time to visit Agra is between October and March. This is when the weather is cool and pleasant.
    tourist attractions in agra

    ReplyDelete
  7. The Taipei Zoo is a world-renowned facility that houses more than 2,600 animals from over 200 species. The zoo is located in the heart of Taipei City
    animals at the taipei zoo

    ReplyDelete
  8. The best time for visiting Pattaya is between November and February when the weather is cooler and drier.
    things to do in pattaya

    ReplyDelete
  9. Church Flyer Templates is offering Free PSD Templates Design, Cards, Posters, Banners, Vectors and Backgrounds images for free and Premium. Enjoy this Template Design
    church flyer

    ReplyDelete
  10. Our guide, written by experts will cover everything you need to know about planning a trip to Mecca, including how to get there, where to stay, what to see
    why visit mecca?

    ReplyDelete
  11. There is no best time to visit Prague. The weather is relatively mild all year round, with temperatures rarely falling below freezing in winter or rising above 32 degrees Celsius in summer.
    what to pack for a trip to prague

    ReplyDelete
  12. "Hi there! I just wanted to drop by and say that I really like your work. Your attention to detail and creativity are truly impressive. Keep up the great work and thank you for sharing your talent with the world!"
    I hope this helps! If you have any further questions, feel free to ask. And thank you for the link to https://apsotech.com/.








    ReplyDelete
  13. Hi, Your blog is very Engaging. Recently I uploaded some content relevent to this blog. Please visit my site Fly Wly; we aim to provide valuable insights and analysis to a broad range of readers, including entrepreneurs, tech enthusiasts, and anyone interested in staying informed about the latest advances in technology and innovation.
    For more Information: https://flywly.com/

    ReplyDelete
  14. At the heart of South Canton Scholars lies a meticulously crafted curriculum that serves as the bedrock of academic advancement. Our curriculum is specifically formulated to promote comprehensive development, utilizing avant-garde teaching methodologies and interdisciplinary modules.

    ReplyDelete
  15. Essential oils are concentrated plant extracts that capture the essence, or fragrance, of the plant. They are derived from various parts of plants, including flowers, leaves, stems, and roots. These oils are highly aromatic and are often used in aromatherapy, skincare, and home remedies. Some popular essential oils include lavender, peppermint, tea tree, and eucalyptus, each with its own unique scent and potential health benefits.

    ReplyDelete
  16. AI voice generators that can replicate Pokimane's voice. It discusses what makes Pokimane popular and why someone might want to use her AI voice. Two Pokimane AI voice generators are explored in detail: TopMediai Text to Speech and Vidnoz Voice Changer. TopMediai offers a user-friendly interface and supports many languages. Vidnoz allows for more customization of the voice.

    ReplyDelete