16u4 leonardo clone, code loads perfectly but won't run

Hey everyone!

I've come across a bit of a problem trying to get a 16u4 based leonardo clone working (Due to the worldwide lack of the 32u4 and a tight deadline, sadly). I've built the board and am using a mega as my ISP programmer. I'm testing with a real leonardo side by side and IT works perfectly - my board can talk to the programmer, set fuses and lock bits, write read and verify the flash...but for some reason, the code never actually runs. Details below.

-Both boards run at 16 mhz and have the same fuse settings (l:0xff h:0xdf e:0xcb)

-My sketch sets all of my boards' output pins to output using DDRx, then turns them all on using PORTx. That's it.

-I've used my mega to turn my leonardo into a bootloaderless fuse-clone of my board, so that the chips are effectively identically configured. It runs anything I care to put on it flawlessly...

-...but when I use the same mega to upload the same code to my 16u4 based board, the damn code doesn't run! The code loads fine, and verifies. I can change the fuses or lock bits, erase the chip, whatever I want. Everything works fine, EXCEPT that the code doesn't actually work!!! Wether I reset it, cycle the power, or re-upload the code...all the pins stay low, as if the chip was lifeless.

-I KNOW The 16u4 is correctly rigged/configured, because I can upload sketches to it. If nothing else, it should be able to bring MISO high, right?

-I'm using avrdude to upload the code arduino 1.0.5 compiles for a leonardo board. I've cleverly tricked everything into working by changing JUST the avrdude config file for the 32u4 to have the 16u4's memory locations. The chips share a datasheet and are otherwise identical, and I'm not using a bootloader, so doing this should be fine, right? The code is barely 4k anyways...

If anyone has any idea whatsoever what could be causing this, that would be fantastic! I can TALK to the bloody chip, change it's fuses, upload code to it...why doesn't it run?! :0

Cheers,

Dennon

The ISCP header to program it with a programmer uses its own clock. It doesn't need a crystal to run.
When you start it to run a sketch, it does need a crystal.

Cheap crystals easily break and stop working below 0 degrees Celsius.

Hey Peter,

Is it true that the MCU doesn't need a crystal to program? When I was doing my research on how to program it, a very common issue with ISP seemed to be that people hadn't configured their crystals properly...so I was fairly confident the oscillator is working!

Dennon

I could be wrong. Sorry. There a few things: writing flash, setting fuses, and some ATtiny chips can be unbricked with HigherVoltage. I'm confused now :blush:

The one at the bottom (left) doesn't have a crystal: http://arduino.cc/en/Tutorial/ArduinoISP
I assume that the internal clock is needed for the bootloader and the sketch, but perhaps not for programming with programmer. But I'm no longer sure.