Step 8Programming the AVR
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 Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|




















































