Practice 1, Theory 1

Written by  on December 30, 2008

As part of getting the new workspace space I moved the toxins related to casting and circuit board fabrication out of my apartment. The theory being that the space is semi industrial.

So as a test of the new space I took one of Alex Normans board designs and etched it.

Since the last time I worked with Alex on his designs he has picked up quite a bit and I only spent about 10 minutes getting his eagle files layed out and printed before going to the office. When I got there I realized that I had forgotten the green trf and bon ami but we were still able to get a reasonable etch and the new space has been broken in on the practice side.

Written by  on December 18, 2008

Since TDI is such a wide ranging beast, we’ve created a more targeted website for the agent-based modeling work TDI does.  Check it out.

Almost ready to work

Written by  on December 9, 2008

I’m almost ready to work here in our new “office”!


Testing the Atmel Mega32U4

Written by  on December 2, 2008

Mega 32 U4

While I am wrangling with the appropriate board design, I needed to get started working with the underlying software so I ran up one of the six samples I was able to get from Cascade on a tqfp adapter from measure explorer.

Schematic For Test Board

The AtMega32U4 is the midrange model in the atmel usb chipset. It follows a new standard naming convention that atmel is adapting U for Usb 4 is for the 40 pins 32k, there is another 32K part the U6 which has the same pinouts as the 90usb646/647/1286/1287. The U4 does not have a legacy pinout however the q1000 price for this board is around $2 which makes it a very powerful chip for the money.


There is a recent release of dfu-programmer (0.4.6) but it seems that they havent read the atmel doc on the signatures for the dfu recently. recently.

I need to check the memory and eeprom sizes against the datasheets for the parts. However the table in arguments.c should have the following entries; added new parts, corrected 64x and 82 signatures. (I will resubmit this patch).

/* ----- target specific structures ----------------------------------------- */
/*  { "name",         value,            ,device_type, chipID,VID   , MemSize,FPSize,abt,ifclass,eepgsz,eepmemsz} */
static struct target_mapping_structure target_map[] = {
    { "at89c51snd1c", tar_at89c51snd1c, device_8051, 0x2FFF, 0x03eb, 0x10000, 128, false, true,  0,   0      },
    { "at89c5130",    tar_at89c5130,    device_8051, 0x2FFD, 0x03eb, 0x04000, 128, false, true,  128, 0x03FF },
    { "at89c5131",    tar_at89c5131,    device_8051, 0x2FFD, 0x03eb, 0x08000, 128, false, true,  128, 0x03FF },
    { "at89c5132",    tar_at89c5132,    device_8051, 0x2FFF, 0x03eb, 0x10000, 128, false, true,  0,   0      },
    { "at90usb1287",  tar_at90usb1287,  device_AVR,  0x2FFB, 0x03eb, 0x1F000, 128, true,  false, 128, 0x0FFF },
    { "at90usb1286",  tar_at90usb1286,  device_AVR,  0x2FFB, 0x03eb, 0x1F000, 128, true,  false, 128, 0x0FFF },
    { "at90usb647",   tar_at90usb647,   device_AVR,  0x2FF9, 0x03eb, 0x0F000, 128, true,  false, 128, 0x07FF },
    { "at90usb646",   tar_at90usb646,   device_AVR,  0x2FF9, 0x03eb, 0x0F000, 128, true,  false, 128, 0x07FF },
    { "atmega32U6",   tar_atMega32u6,   device_AVR,  0x2FFB, 0x03eb, 0x07000, 128, true,  false, 128, 0x03FF },
    { "atmega32U4",   tar_atMega32u4,   device_AVR,  0x2FF4, 0x03eb, 0x07000, 128, true,  false, 128, 0x03FF },
    { "atmega16U4",   tar_atMega16u4,   device_AVR,  0x2FF3, 0x03eb, 0x03000, 128, true,  false, 128, 0x01FF },
    { "at90usb162",   tar_at90usb162,   device_AVR,  0x2FFA, 0x03eb, 0x03000, 128, true,  false, 128, 0x01FF },
    { "at90usb82",    tar_at90usb82,    device_AVR,  0x2FF7, 0x03eb, 0x01000, 128, true,  false, 128, 0x01FF },
    { NULL }

Then we test.

dfu-programmer atMega32U4 get bootloader-version --debug 20
     target: atMega32U4
    chip_id: 0x2ff4
  vendor_id: 0x03eb
    command: get
      quiet: false
      debug: 20
device_type: AVR
------ command specific below ------
       name: 0

Bootloader Version: 0x00 (0)

(after reading the datasheets for the 3 classes of avr usb chips and looking at the way that the avr-gcc library calls the cpu names there are some changes to the above that I will post later.)

Next up some code.

Tried running up the midiGate software that I wrote last week and found my first bug for the chip in avr-libc

UBRR1 is redefined in iom32u4.h

#define UBRR1 _SFR_MEM16(0xCC)

#define UBRR1L _SFR_MEM8(0xCC)
#define UBRR0 0
#define UBRR1 1

Which results in lvalue errors errors when trying to set the register to a given value. Setting the bit values as in some of the other registers seems to resolve this issue.

#define UBRR1 _SFR_MEM16(0xCC)

#define UBRR1L _SFR_MEM8(0xCC)
#define UBRR_0 0
#define UBRR_1 1
#define UBRR_2 2
#define UBRR_3 3
#define UBRR_4 4
#define UBRR_5 5
#define UBRR_6 6
#define UBRR_7 7

#define UBRR1H _SFR_MEM8(0xCD)
#define UBRR_8 0
#define UBRR_9 1
#define UBRR_10 2
#define UBRR_11 3

This is a pretty braindead error so I am sure that its been resolved by now. I need to see if it is fixed in 1.6.3 or the current release candidate (since AvrMacPack is out of sync and has 1.6.2) And yes this is the case.

We have a device!!!

Fix(ing) it!

Both of these issues were easy enough to fix within the source of the utilities but to make it possible for everyone else to use the new chips some body needs to Fix it! So I went about looking up the chain to get these issues resolved over the long run.

Dfu Programmer.

dfu-programmer is a source forge project so I logged an error through the sourceforge project page. A new release has been made (0.5.0) which resolves the issue above.


Since avr-libc is a savanaha project and so making bug requests is a little different. Fortunately (sort of) I had already been around the buggier parts of the release in question (1.6.2) when I first ran up the at90usb647. When Eric Weddington released the June rev of WinAvr (with avr-libc 1.6.3) I thought I had seen the last of it as obdev released the coresponding AvrMacPack. The bug noted above was fixed in 1.6.3 and I was able to verify that using my windows vmware session. For some reason this was not the case and AvrMacPack went out with the buggy (for this new chip anyway) libc. I filed a bug report with obdev and followed up with Christian from obdev and Eric until the version descrepency was resolved. The new version of WinAvr just came out and I am waiting to verify that the AvrMacPack version matches WinAvr.

If you are running linux plan on building from source and patching as in the script kept current at avrfreaks (you will need to log in) . This script has not been updated for the latest winavr but it should at least give you a version above 1.6.2.