ATTiny85 programming issue

Hi all,

I've been trying to program an ATTiny 85 with avrdude using an Arduino uno as ISP. The program seems to upload fine (see below) but then it just does not run on the tiny, once it's done uploading.

I don't think it's a wiring issue, I tried with a tiny13 and had the same outcome. Must be something I'm doing wrong in the avrdude command?

I tried 9600 bauds and it failed. I set the fuses on the tiny to run at 8MHz on the internal oscillator.

Any help would be appreciated!

Cheers

Fred


C:\avrdude -C ..\etc\avrdude.conf -c arduino -p attiny85 -P com5 -b 19200 -D -U flash:w:blin k.cpp.hex

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85 avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e930b avrdude: reading input file "blink.cpp.hex" avrdude: input file blink.cpp.hex auto detected as Intel Hex avrdude: writing flash (916 bytes):

Writing | ################################################## | 100% 1.62s

avrdude: 916 bytes of flash written avrdude: verifying flash memory against blink.cpp.hex: avrdude: load data flash data from input file blink.cpp.hex: avrdude: input file blink.cpp.hex auto detected as Intel Hex avrdude: input file blink.cpp.hex contains 916 bytes avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.18s

avrdude: verifying ... avrdude: 916 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.

Have you adjusted blink to blink a pin that exists on the tiny85? (ie, 0, 1, 2, 3, or 4) Did you compile blink for the tiny85? If you used the IDE, did you have the attiny85 selected from boards menu? (if it's not an option in boards menu, you haven't installed a core that supports the '85, and need to do that)

Have you checked all pins with a multimeter to make sure you're not just blinking the wrong pin because the pin mapping isn't what you think it is? I know there are two cores with different mappings for the '84.

When you read out the fuses with avrdude, do they all have the right values? What are they?

The program seems to upload fine (see below) but then it just does not run on the tiny, once it's done uploading.

Sadly, you haven't posted your program. Which is a requirement for getting help with it.

Hi Guys,

Thanks for your replies!

  • My program is just the blink example with the pin changed to 0, see below:

int led = 0;

void setup() { pinMode(led, OUTPUT); }

void loop() { digitalWrite(led, HIGH); delay(1000); digitalWrite(led, LOW); delay(1000); }

  • I did compile the program for ATTiny @8Mhz (internal osc), I installed core files for IDE 1.5.2 and I had no errors while compiling
  • I have checked the pinout carefully to make sure, and I plugged my LED to the pin 5 of the housing (it's a DIP package). I will check voltages again, I was not aware the core may change actual pin mapping
  • The fuses were set as follows: low fuse: 0x62, high fuse 0xdf extended fuse 0xff

Cheers,

Fred

and with attiny85 1 MHZ?? that works here :)

Hi again,

To make sure, I compiled it on IDE 1.5.2 with the 1Mhz setting and copied the program again using the proper fuses from http://www.engbedded.com/fusecalc/:

Seemed to work but I still read 0v or 1v max on the pins :(

Cheers, Fred


avrdude -C ..\etc\avrdude.conf -c arduino -p t85 -P com5 -b 19200 -D -U lfuse:w:0x62:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -U flash:w:blink.cpp.hex

avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85 avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e930b avrdude: reading input file "0xdf" avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.02s

avrdude: 1 bytes of hfuse written avrdude: verifying hfuse memory against 0xdf: avrdude: load data hfuse data from input file 0xdf: avrdude: input file 0xdf contains 1 bytes avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ... avrdude: 1 bytes of hfuse verified avrdude: reading input file "0xff" avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of efuse written avrdude: verifying efuse memory against 0xff: avrdude: load data efuse data from input file 0xff: avrdude: input file 0xff contains 1 bytes avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.02s

avrdude: verifying ... avrdude: 1 bytes of efuse verified avrdude: reading input file "blink.cpp.hex" avrdude: input file blink.cpp.hex auto detected as Intel Hex avrdude: writing flash (916 bytes):

Writing | ################################################## | 100% 1.57s

avrdude: 916 bytes of flash written avrdude: verifying flash memory against blink.cpp.hex: avrdude: load data flash data from input file blink.cpp.hex: avrdude: input file blink.cpp.hex auto detected as Intel Hex avrdude: input file blink.cpp.hex contains 916 bytes avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 1.13s

avrdude: verifying ... avrdude: 916 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.

At low fuse 0x62, it's running at 1mhz, not 8mhz.

If you compile for 8, but it's running at 1, your code will run 1/8th as fast as you expect it to. In the case of blink, you could thus easily measure every pin in the 8 seconds that the pin isn't high for, and incorrectly conclude that the sketch isn't working.

Yes indeed, you are perfectly right. But on my last attempt I both compiled at 1Mhz and set the low fuse at 0x62 to sidestep that problem.

I also hooked a led to the 0 pin so I could notice a really slow or really fast blink.

Important info I forgot to share, I'm using avrdude because when I try to program the ATTiny with Arduino as ISP, I get the 'stk500_getsync(): not in sync: resp=0x00' error...

Maybe the fault lies in the core files I'm using to compile?

Cheers,

Fred

The processor has either an indent in one corner or a half circle on one side. The indent marks physical pin 1. The half circle marks the "top" with pin 1 to the left. Physical pins are numbered sequentially from the upper-left to the upper-right. Arduino digital pins are [u]not[/u] numbered this way.

On which physical pin did you connect the LED and the current limiting resistor?

I also hooked a led to the 0 pin so I could notice a really slow or really fast blink.

And a current-limiting resistor?

int led = 0;

That's pin 5 on the chip.

Hello,

I added a current limiting resistor to the led (220ohm) and the LED blinks when I am uploading the program.

The LED is connected to physical pin 5 = I/O pin 0. Needless to say, VCC is connected to pin 8, GND to pin 4 and reset to pin 1. I tried uploading with and without 10µF cap, both appear to be working...

Cheers

Fred

So the problem was the missing current limiting resistor. Good to know.

Seemed to work but I still read 0v or 1v max on the pins

That was the clue.

Must be a red LED (Vf=~1V). If it had been blue the thing may have run (for a bit). :smiling_imp:

Sorry guys I think you got me wrong here: the resistor was there from the very start, the LED blinks while I upload because it signals action on the MOSI pin (or MISO, I don't remember).

But once it's done uploading, nothing! I does not blink and I read 0v on the 0 pin.

I read 1v on the 1 and 2 pins, and 5v between VCC and GND, and 5v between RST and GND.

It's a yellow LED ;)

FredX10: Sorry guys I think you got me wrong here...

Either that or you failed to include important relevant information. I suspect the latter.

FredX10: I read 1v on the 1 and 2 pins, and 5v between VCC and GND, and 5v between RST and GND.

As far as I can tell that leaves four possibilities...

  1. You compiled the sketch for a processor running at 8 MHz but the processor is running at 1 MHz (or 128 kHz). Watching the LED for ~65 seconds will determine if this is the problem.

  2. You damaged the processor. Try a different pin.

  3. You inadvertently enabled the watchdog fuse. Use the IDE to change the fuses (Tools / Burn Bootloader).

  4. The processor is defective from the vendor.

Hmm. Can you try this code please:

void setup() 
{               
  DDRB = bit (0);   
}
void loop() 
{
  PINB = bit (0);
  delay(1000);
}

Some versions of the Attiny libraries map pins in unusual ways. This directly addresses the hardware. The pin on port PB0 should blink.

Hi again,

Thanks for your reply.

I think the problem may lie in the core files I'm using for Arduino IDE. At first I tried uploading the sketch directly to the tiny, using my Arduino Uno as ISP. But as I was getting "not in sync" errors, I switched to avrdude.

There I made a mistake because I uploaded a program compiled for the uno (the program I pasted in the thread after Nick's response). After that I started compiling for the ATTiny @1MHz. As I was trying again tonight, I noticed the IDE says that the blink program is only 2 bytes, which can't be good. So I think I'm just uploading almost nothing to my ATTiny.

I have IDE 1.5.2 with core files from https://code.google.com/p/arduino-tiny/ and I also tried on IDE 0022 with another set of core files. Despite my lengthy research I cannot seem to get the right core files: IDE 1.5.2 displays ATTinys in the boards menu but fails to compile, and on IDE 0022 I don't see the tinys in the boards menu :(

So for now, I cannot verify your suggestions 2/ and 4/

Regarding suggestion 3/, the fuses I burned from www.engbedded.com/fusecalc/ with avrdude should disable the watchdog fuse, right?

Thanks again for your valuable advice!

Cheers, Fred

Thanks for the suggestion Nick!

Is there any way I can compile the code without using Arduino IDE? As I wrote above I think my core files don't work...

Cheers, Fred