Bohack

Check In and Tune Out!
 
 
« Compacting Microsoft Virtual PC VHD Images 101
Get the URL from a hyperlink in Excel »

Bascom-AVR and the Atmel ATtiny2313



Back in April I attended the Notacon the hacker-art convention up in Cleveland Ohio. The hardware hacking room had a number of little project kits they were giving out to teach people how to solder. These project kits included the chips, resistors, LEDs, serial connector and everything except the solder. They ran labs and the last day they just wanted to get rid of these project kits. So I grabbed a couple that caught my eye. One kit had an Atmel AVR programmable chip, eight LEDs and sported a 9-pin serial connector. The kit is the Mini-POV3 sold by http://www.adafruit.com/ for $17.50, it’s all you need to get started with programmable chips!

So I got home that Sunday and my son and I put the Mini-POV3 kit together, it took all of 30 minutes. It is a persistence of view kit, so when you wave the device it spells a word or words out. This concept unfortunately is not something that a 4 year old can grasp and he is like “Wow, what else does it do?”

The heart of the kit is an Atmel AVR ATtiny2313 8-bit RISC Microcontroller; it has programmable inputs and outputs, 2KB of flash memory and can be programmed in-system. The design was ahead of its time and AVR stands for the two designers’ names “Alf and Vegard’s Risc”. The kit also comes with a 9-pin Serial connector. So a couple of tasks to program this thing…

  1. Build the project (takes about 30 minutes).
  2. Get a straight thru serial cable or directly plug it into the serial port.
  3. Download WinAVR from http://www.sourceforge.net/
  4. Download Bascom-AVR Demo from http://www.mcselec.com/
  5. Learn some QBasic and the inner workings of the Atmel AVR.

Install the WinAVR program, this program will allow you to program the in-system Microcontroller. When you install it: change the path to “c:\WinAVR” and make sure that it puts the AVR binaries in the global path variable; you will be prompted during the install. Now we need to install the Bascom-AVR program which is the IDE or Integrated Development Environment and the Bascom BASIC to machine code complier. To install the Bascom-AVR program accept all defaults during the install, we will set it up next…

Inside of the Bascom-AVR program click on the ‘Options’ menu item and select ‘Programmer’. This is where we setup the tie between the WinAVR program called AVRDude.exe and the Bascom IDE for one click programming. Although you always have the option to find the BIN file and flash it via command line. Click the pull-down menu for Programmer and select ‘External programmer’ now in the tab below called ‘Other’ set the ‘Program’ to the path of the avrdude.exe; so it should look like this “C:\WinAVR\bin\avrdude.exe”. In the ‘Parameter’ field put “-p t2313 -P com1 -c dasa -U flash:w:{FILE}:a”; which tells avrdude.exe to write to a tiny2313, via comport 1, using direct access (dasa) and write to flash, substitute {FILE} for the filename and program it automatically. You can always Google ‘avrdude man’ for the manual page for the avrdude program or just type mine in.

Bascom Options for Programmers

Now let’s compile and program the equivalent of a hello world application… However if you want to backup the original program drop to a command prompt and type “avrdude -p t2313 -P com1 -c dasa -U flash:r:backup.hex:i” and you can always write it back via “avrdude -p t2313 -P com1 -c dasa -U flash:w:backup.hex:i”. Now open a new project in Bascom-AVR by clicking File-New and type the program in below, then hit ‘F7’ to compile and ‘F4’ to program to the chip. During this process the power switch must be in the ‘On’ position, remember you are programming a single chip computer!

The outcome when disconnected from the serial port is: a sequential lighting of the LEDs in 2 second intervals. Now it is time for you to learn some Bascom BASIC and play with the programming yourself. Start by downloading the Bascom-AVR PDF file and reading it. You can also customize my program to make the lights blink back and forth. Start by changing the timing to 1 second, then set your next goal and learn some of the language. Happy Hacking and visit some of my sponsors for deals on AVR products (I get paid when you visit them).

'Sequence LEDs
Dim X As Byte
Config PortB = Output
PortB = 0

For X = 0 To 7
 Wait 2
 PortB.X = 1
Next X

End

Tags: Electronics, Hacking, Programming

This entry was posted on Saturday, May 30th, 2009 at 12:00 pm and is filed under Homebrew.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.

One Response to “Bascom-AVR and the Atmel ATtiny2313”

  1. Bocas del Toro Says:
    April 22nd, 2010 at 11:25 pm

    I am unquestionably bookmarking this website and sharing it with my acquaintances. You will be getting plenty of visitors to your website from me!

  • Channels

    • Beer (2)
    • Blog (1)
    • Exchange (2)
    • Ham Radio (1)
    • Homebrew (3)
    • Linux / Unix (4)
    • Misc (1)
    • Mods (4)
    • Networking (1)
    • Programming (4)
    • Recipes (2)
    • Scripts (7)
    • Security (1)
    • Software (2)
    • Spam (1)
    • Telco (7)
    • Virtual PC (1)
    • VMware (3)
    • VOIP (3)
    • Windows (16)
    • Windows 2008 (4)
    • Windows 7 (5)
  • Archives

    • September 2012
    • April 2012
    • March 2012
    • February 2012
    • January 2012
    • November 2011
    • September 2011
    • July 2011
    • April 2011
    • February 2011
    • January 2011
    • October 2010
    • August 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • June 2009
    • May 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
  • Links

    • Blogarama Blogarama – The Blog Directory
    • BlogHub Blog Directory
    • Blogrankings Technology Blogs – Blog Rankings
    • Blogville.us blogville.us
    • Buzzerhut free directory | buzzerhut.com
    • Ontoplist Online Marketing
    • Primechoiceautoparts Discount Auto Parts
    • PTC My Employer
 

  Copyright - Bohack 2025 ©