Cannot read device signature. Stuck in debug mode???

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Using: Waveshare AVRISP xpII -> recognized as an AVRISP mkII from Atmel

ATTiny13V -> Atmel Studio provides ATTiny13 and ATTiny13A as device options and ATTiny13A seems to program it

Atmel Studio 7

 

I am a beginner and was eventually able to program the attiny. I checked it first with the LED blink code. I then programmed it with the code I actually wanted and put it in my circuit. It did not behave as I had wanted, I think because of the clock settings during the programming (I may have programmed it with a clock of 250kHz instead of 1.2MHz as I wanted so my timing was off..I think). So, I set out to reprogram it and I cannot escape this:

 

Issue: 

Timestamp: 2017-09-18 10:34:01.349

Severity: ERROR

ComponentId: 20100

StatusCode: 1

ModuleName: TCF (TCF command: Device:startSession failed.)

 

Failed to enter programming mode. ispEnterProgMode: Error status received: Got 0xc0, expected 0x00 (Command has failed to execute on the tool)

 

My connections from the programmer to the chip are correct complete with a 15kOhm pullup resistor on Reset. I also have 0.1uF bypass capacitors on supply and chip Vcc to ground

I have seen this issue on previous forums with different solutions, but am confused by the rhetoric. 

 

Something about being unable to exit debug mode? I have attached a picture related to this. This is because reset is disabled?? Or maybe my programmer cable is just worn? (though I doubt it as it is basically new). These are just things mentioned in forums, I am not actually sure what is going on. please help!

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

IIRC the t13 does not have a debug mode, so ignore that.  If the clock is slow, you must set the isp clock to 1/4 the cpu clock or lower, so try the slowest setting available.

Then restore the chip to factory default.  Then set the isp speed back to normal.

If by chance you set the fuse to disable the reset pin, the only hope of recovery is HSP, High voltage serial programming. 

May be best to just trash bin it and move on to another.  Lesson learned.

BTW: the tiny 25/45/85 is pin compatible with the 13's, and have more space to prototype in....

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So I reordered some new ATTiny13V's and just tried your suggestion with the clock speed on a new tiny. I set the clock speed to 125kHz (before I had 1.2MHz) and it read the signature!

 

So there are two places I can set the clock speed: first is when I go to the "Solution Explorer" and right click on my "project file" to find "properties". In properties I go to "tool" and select my avrisp mkII and choose the clock speed there. Then I build my solution.

Second is when I go to "device programmin" in the "tools" menu. Here I select my avrisp and attiny and click apply. I then am able to select clock speed again.... 

 

What is the difference between these two times I am able to select clock speed?? I want my tiny to run with 1.2MHz clock because I believe the timing in the code I want to program on my tiny depends on this (I did not write the code and don't understand assembly so it's my guess)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I understand it can all be confusing, it does take awhile to make sense of it.

 

The MPU (tiny13 in this case) has an internal cpu clock, the fuses are used to determine what this source is, (internal rc/external xtal or oscillator) and speed.

 

The toolchain used to develop the program will have a method to tell the tools what speed the cpu is running at, (example F_CPU), but this does not have any effect on the cpu itself, it is only used by the IDE for calculations involving timing and baud rate. Many think this will change the cpu clock speed, it does not, but should match the actual speed of cpu in order for the calculations to work correctly.

 

The device used to burn the code(atmel-ice, draggon, isp mkii, usbasp, etc) into the cpu flash memory also has a speed setting, this one must be 1/4 the actual cpu speed max. 

So its important to KNOW what the actual cpu speed is, for these things to work as expected.

 

Hope that helps clear up the three different "speeds" you need to understand for successful programming and operation.

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Attiny13 comes from the factory with the clock set to 9.6 MHz.

You can divide the clock by 2, 4, 8, 16 etc. in the code using CLKPS register.

With #define F_CPU you tell the compiler the true frequency of the chip. 

See  the description of CLKPS register in datasheet.

 

 

#define F_CPU 1200000UL
#include <avr/io.h>
#include <util/delay.h>


int main
{
   CLKPS = (1<<CLKPCE);  // Clock Prescaler Change Enable
   CLKPS = 3;            // Set prescaler to 8   (9.6 / 8 = 1.2 MHz)
    
// your code

}

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The default fuse settings also set the /8 clock, so the default cpu speed is 1.2MHz, this can be changed using the CLKPS register as noted above.

 

Jim

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The default fuse settings also set the /8 clock, so the default cpu speed is 1.2MHz

Oh, I should have read more carefuly. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great info thank you. So then, why am I able to read the device signature when I set my clock speed to 250kHz and not when I set it to 1.2MHz? Like said above, my tiny has a cpu clock of 9.6MHz. Also, what happens if I don't set the clock speed to 1/4 of the max cpu? Say I go to 250kHz (as I have) or I go to 5MHz?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Like said above, my tiny has a cpu clock of 9.6MHz

But it doesn't, unless you've changed the fuses i.e unprogrammed the CKDIV8 fuse in the low fuse byte.

 

As mentioned the factory default behaviour of the t13 is to run >>from<< the 9.6 MHz calibrated internal RC oscillator, but with a clock prescaler of 8, resulting in a clock speed of 1.2 MHz.  One quarter of that is 300 kHz, so your ISP programming clock must be less than that.  250 kHz meets that requirement.  1.2 MHz does not.

 

Also, what happens if I don't set the clock speed to 1/4 of the max cpu? Say I go to 250kHz (as I have) or I go to 5MHz?

It won't work :)

 

Or worse, the AVR will decode uncommanded ISP instructions and commit suicide.  Although this isn't very likely.

 

Don't do it.

 

Beware:  Unless you know what you're doing, don't fiddle with the fuses.  It is possible to render your AVR unreachable, or at least difficult to reach without specialised programming equipment.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

 

sebe16:

 

Do not mix the two frequencies:

 

1. Frequency of the internal clock inside the Avr (cpu clock, F_CPU).

    This frequency is set to 1.2 MHz from the factory.

 

2. ISP programming frequency (ISP clock). It controls the speed of flash programming.

    Must be less than actual (cpu clock / 4)

 

 

Also, what happens if I don't set the clock speed to 1/4 of the max cpu

Not "1/4 of the max cpu", but  1/4 of the actual cpu clock.

max cpu clock = 9.6 MHz

actual cpu clock = 1.2 MHz

 

 I checked it first with the LED blink code. I then programmed it with the code I actually wanted and put it in my circuit. It did not behave as I had wanted, I think because of the clock settings

You mean the timing was wrong?

Then you either used wrong value in #define F_CPU (should be F_CPU 1200000UL)

or did not define it at all, in which case the compiler uses F_CPU 1 MHz.