3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Custom Tron Disc Mod

Step 8Programming the AVR

Programming the AVR
ENVIRONMENT
If you need information on programming AVR MCU's, I used AVRStudio for another AVR project I did, but I recently found an Instructable on using Eclipse as an IDE .  I like Eclipse much better, but it's all personal preference.

PROGRAMMING
There are plenty of Instructables about getting started with AVR programming.  I've included my Eclipse projects which include the C source files, as well as the precompiled .hex files. 

If you're using an ATMega328/168 - use the TronV1 files.  If you're using an Attiny45, use the TronTiny files.

Both implementations are running the chips at the full 8Mhz using the internal oscillator. Other than that, I'm using standard fuse bits - although you could add brownout detection as the MAX72XX chips stop working at 4v.

UNDERSTANDING THE PROGRAM
If you're not interested in modifying or understanding the code - you can skip this section :)
Communication to the Max7221/7219 consists of two bytes - one byte indicating what value (command register) we're updating (settings, values for a segment, etc).  The second byte contains the value to write. 

Each segment of 8 LED's are addressed through a series of bits (8 bits = 1 byte).  So, for instance - the following binary value will turn on only LED1 - 00000001.  The following value turn on LED 8 - 10000000. 

Commands are sent to the chip using the sdp8 function.  Register names and helper functions can be found in the LEDControl.h file. 

There are a few differences between the Tiny and Mega implementations.  ATTiny45 doesn't support SPI, so I found some code to use USI instead (AVRFreaks.net is a great source). There are some port and pin differences as well - understanding considering one is an 8 pin MUC, and the other has 28 pins.

You should be able to port this to a large number of AVR chips, provided you configure the timers and ports correctly.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
3
Followers
3
Author:cubeberg(My Blog)
I'm a .Net Developer - an avid Instructables reader. I'm an beginner, but I've got a lot of patience. Thank goodness there is so much information online! I'd like to get eventually get into robots ...
more »