[McHUG] Butterfly update.

Rich Mitchell geobra at att.net
Sat Mar 15 17:58:55 EST 2008


At the February club meeting Steve gave me a Butterfly  and Joe Pardue's book on 
programming the Butterfly in C using WinAVR.  The Butterfly was the name tag 
thing I was demoing at the March club meeting and was also the door prize.  
Well, this weekend I began a very interesting project.  The book and its CD were 
based on WinAVR from April 2004.  I installed the most recent WinAVR from 
December 2007 and tried to run my demo program.

The compiler bombed because it couldn't recognize some of the pin/port names.  
Over the past three and a half years several of the names have changed.  What 
you had to do was find the iom169.h file from 2004 and compare it with the 2007 
file to find the updated names and change these in the program.

Once that was done, the compiler started complaining about sbi() and cbi().  
Joe, in his book, mentioned that these were deprecated but said we'd use them 
anyway.  Well, in 2007 they weren't just deprecated, they were gone!  A little 
surfing showed it was a very simple replacement.  sbi stood for set bit and cbi 
for clear bit.  (set interrupt sei() and clear interrupt cli() still work.)  
Here's how I updated the code.
    ADCSRA &= _BV(ADEN);  //cbi (ADCSRA, ADEN);
    ADCSRA |= _BV(ADEN);  //sbi (ADCSRA, ADEN);

With these changes made my code compiled, but built a module for AVR Studio with 
errors.  I use AVR Studio to load the code into the microcontroller.  I ended up 
loading the .hex file into AVR Studio, not the .coff and was able to program the 
Butterfly.  I tried to program the Butterfly using AVRDUDE but there is some 
kind of problem:

C:\AVR Programs\NameTag2b>make program
avrdude -p atmega169 -P com2     -c butterfly  -v -v  -U flash:w:Demo.hex
. . . . . . . 
         Programmer Type : avr910
         Description     : Atmel Butterfly Development Board

Connecting to programmer: .
Found programmer: Id = ""; type = H
    Software Version = +. ; Hardware Version =  .j
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
make: *** [program] Error 1

Steve, if you have any ideas let me know.  I'm still modifying the original file.  I have not tried the facility that creates a new make file.

WHY IS THIS IMPORTANT????  If we can compile our code and program the 
microcontroller using just the command line, we can use some very simple (old) 
computers to develop our code - certainly dumpster grade, maybe landfill grade.  
And then we can use that tool chain to process our Arduino code, which means we 
won't have to rely on their Java IDE.  The Arduino libraries will hide the C 
complexities while the command line tool chain would allow us to use old 
machines.  Also you would be able to switch between Windows and Linux and still 
have the same development process.  And yet if you needed to, or wanted to, you 
could develop in straight C.

If we can get a command line tool chain working, you would build and deploy your code with just 3 commands:
make clean
make all
make program
The trick is to get the parameters in the make file right.

Welcome to Dick K3KWL who joined us last night.  We are now 7:
Dick K3KWL
Bill W3STG
John K3KWO 
Chuck KJ4GU 
Steve N3SB 
Pete W3GVX
Rich N3III

73,
Rich, N3III
--
McHUG - Physical Computing ;)
MicroController Ham User Group


More information about the McHUG mailing list