Does anyone have any experience with the ATTINY5 ?

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

Hi

I thought this little chip might be ideal for a little mission I have - read the ADC, switch a fan on/off when appropriate.

I am doing this with an ATMEGA16 - written in CodevisionAVR, programmed with the AVRISP Mk2.
No worries. Now I would like to do the same thing on this little and cheap chip.

But....

When I read the datasheet, it doesn't have the usual MOSI/MISO/RESET/CLK that is used for programming.

So, how do you program these things? Do I need some other device?

Thanks
Pete

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

Quote:

So, how do you program these things? Do I need some other device?

They use a new programming method called TPI. Luckily for you the latest AVRISPmkII firmware allows it to do TPI. You may need to switch to AVR Studio to do the actual programming though (I don't know enough about CV and don't know if the latest versions have TPI support).

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

Hi
Thanks, I will look for a firmware upgrade.

I use an old version of CVAVR, so I always use AVR Studio to load the hex files anyway!

Thanks for your help!
Pete

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

Quote:

Thanks, I will look for a firmware upgrade.

Just make sure you are using the very latest stable AVR Studio (4.18SP3) and when you connect to the AVRISPmkII it will announce that the firmware is out of date (if it is) and then update it.

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

Quote:

I use an old version of CVAVR, so I always use AVR Studio to load the hex files anyway!

??? If you are using an old version of CV, how are you able to do a build for a Tiny5?

AFAIK CV's programmer facilities support all the chips it can build for.

Quote:
V2.03.9 Commercial Release

* added support for the ATA6285, ATA6286 and ATA6289 chips in the Compiler and Programmer
* added support for the ATtiny10 chip in the Compiler, CodeWizardAVR and Programmer...

There were some Tiny10-family refinements, but the support was there ~December-2008.

(While I will occasionally use 'Studio for some work, very rarely is it ISP. CV supports more programmer types, Program Chip is right there after a build, the project already "knows" what the target is and the clock speed, more options for reading/editing.)

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

theusch wrote:

??? If you are using an old version of CV, how are you able to do a build for a Tiny5?

Don't worry, I have a cunning plan! :)

The free version of CodeVison supports the Tiny5, so I will use that. It's limited to 2k code space, but the tiny5 is less than that anyway!

Cheers
Pete

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

Does that cunning plan have legs and a tail?

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

Does Pavel not give free updates to registered owners then? Why wouldn't you just simply contact him at HPInfotech and tell him that you want to develop for T5 and need an update for your registered copy of CV?

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

ka7ehk wrote:
Does that cunning plan have legs and a tail?

Jim

It's so cunning you could pin a tail on it and call it a weasel!

edit: oops, I see you beat me to it in your sig!

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

clawson wrote:
Does Pavel not give free updates to registered owners then? Why wouldn't you just simply contact him at HPInfotech and tell him that you want to develop for T5 and need an update for your registered copy of CV?

Hmmm. I just assumed it would cost. (I'm still using V1.24 - hey, it does everything I have needed up til now!)

I will email and ask - thanks for the suggestion.

Pete

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

1) Pavel has to eat, too. And support Adriana in the manner to which she has become accustomed.

2) If the eval version works for the Tiny5, then wouldn't it program it as well?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

theusch wrote:

If the eval version works for the Tiny5, then wouldn't it program it as well?

It shows all the settings for Tiny5, so it should.
I don't mind even if I have to use AVRStudio for programming, its what I'm used to.

Since there are a few of you helpful people reading this thread (thanks!), here's another question:

What is the pinout for the programming header?

I found this info in another forum, for another brand of programmer/software (avrdude, i think):

AVRISP - ATTINY5
1 MISO - 1
2 Vcc - 5
3 SCK - 3
4 MOSI
5 RESET - 6
6 GND - 2

Does this sound about right?

I couldn't find any info about it on any atmel site, couldn't find any hobbyist projects to copy from etc.

Thanks!
Pete

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

clawson wrote:
Does Pavel not give free updates to registered owners then?

I checked with them - you get 1 years worth of updates with your purchase.

So I will try with the eval edition first, and if it works and it looks like I will be doing more with Tiny5s in the future, I will get The Boss to buy the upgrade.

Cheers
Pete

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

Quote:

Does this sound about right?

How does it compare with the information in the Programming Interface chapter of the datasheet?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Another source of info about TPI is to run AVR Studio (I'd trust being able to find it more in AS4 than AS5!) and look for the AVRISPmkII user manual which has a section on TPI.

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

theusch wrote:
Quote:

Does this sound about right?

How does it compare with the information in the Programming Interface chapter of the datasheet?

I do actually read the datasheets etc. before I ask for help, (honest!) but I couldn't make much sense of it.

The datasheet explained the timings of the pulses etc necessary to program the chip. It doesn't explain a pinout to connect it to the AVRISP2.

For example, the TINY5 needs a line called TPIData.
The outputs from the AVRISP2 are MOSI MISO RST CLK.
Nowhere in any atmel documentation can I find any info as to which one of these lines outputs the TPIData signal.

The AVRISP2 product page at atmel.com told me that it supports the TINY5, but when I read the user manual on the next page, it is not on the list of supported devices! So no help there!

I am not trying to understand exactly how the programming system works. I am just trying to find out how to plug a programmer into the chip, and have it transfer the software I write, exactly as it does with the MEGA8, 16 and 64.

I have no idea about the timing or protocol of those, but I use them all the time by simply plugging in the AVRISP2 and pressing connect.

I was hoping atmel would provide similar ease of use for the TINY5, and I think they probably have, they have just forgotten about us mere mortals who need a little help getting started!

I know that a lot of visitors to this forum expect all the work to be done for them ("I have a project due, please send me all code asap!!!!!!!!"), but that is not what I am trying to do.

I was just hoping to benefit from the experience of someone who has used a TINY5, and could help me out with a - "yes, that's how I did it", or "No you have swapped 2 lines over".

Hopefully my first ATTINY5 chips will arrive tomorrow, so I will hook one up as per the only pinout that I have found, and see what happens - will report back with an update!

Cheers
Pete

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

From AVRISPmkII manual in Studio...

Attachment(s): 

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

That's brilliant, thanks!

I was reading the manual on atmels website, and it didn't have any of that info.

Right, so I've got:
-Up to date version of Codevision
-Up to date firmware on the AVRISP
-A reliable pinout

All I need now is my chips, and I'm ready to make a start.

Thank you all for your help - stay tuned for exciting developments :-)

Pete

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

I use only the ATtiny25 as my smallest workhorse.
I have no reason to be smaller.

But its easier for developing to grap the DIP-case and put in on a breadboard.

Peter

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

It Works!

I have successfully hooked up the ATTINY5, and got it running a 'hello world' program (flashing an LED)

I had a bit of trouble to start with - I had the LED attached to PORTB.0 (TPIData), so it acted as a short circuit, and wouldn't let me program.

Normally I don't share the programming pins with anything else, but when you only have 4 I/O pins, you don't have much choice!

Attached a couple of pics.

What a great little device - although it's not the easiest for prototyping, it will be fine once its on a PCB.

Thank you all for your help!

Pete

Attachment(s): 

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

Buy a Tiny2313 or any Tiny with a reasonable number of pins.

Do all your development and debugging on that chip.

Once you have everything working ok, re-compile for your Tiny5. Burn and run on the Tiny5.

Much the same approach can be used on a Mega. However most Megas start off with a reasonable number of pins for most projects.

Yes. I know it is satisfying to have a simple project running on six pins. But I would guess that it did not work perfectly the first time! And you probably do not want to go soldering on each iteration.

David.

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

Do yourself a favor and get one of those SMD to .1" adapter PC boards! You can usually find cheap ones on ebay, or get the good ones (for about $10 each) from http://www.schmartboard.com/
Prototyping "deadbug" style can lead to DEADBUGS real fast!

BTW doesn't the tiny5 also support debug-wire for programming?

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

Quote:

BTW doesn't the tiny5 also support debug-wire for programming?

No. Remember these are the most brain dead of brain dead AVRs. There's not enough silicon for anything like a debug interface (yet another reason why they may make a cheap deployment platform but an atrocious development platform - as David says - do development on a "big" AVR with all the toys then scale the design down for final deployment.

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

It would be nice if they could put just the programming interface part of debug-wire on these chips. Then you could program them by only wiggling the reset pin!

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

petenz123 wrote:
What a great little device - although it's not the easiest for prototyping, it will be fine once its on a PCB.
kscharf mentioned SchmartBoard. An alternative is BusBoard; their thin SMT boards can be cut to size.

"Dare to be naïve." - Buckminster Fuller

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

kscharf wrote:
Do yourself a favor and get one of those SMD to .1" adapter PC boards! You can usually find cheap ones on ebay

Oooh, that looks easier!

I sort of have my prototype working, but I don't trust the dead bug wiring.

I have the LM35 temp sensor attached, and switching on an LED when it gets hot, it does some random switching on and off when it shouldn't, then eventually locks up!

I wonder if the wiring is picking up stray mains hum etc.?

Still, we've made a start!

Thanks
Pete

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

Which is why you debug a project in the first place!

Many people seem to be attracted to the low pin count Tinys. Yes. They are fine for running debugged code.

They are not so easy to develop on. And think about it. If you are producing 10,000 items the lower price of a Tiny is attractive. The cost of a single 'big' Tiny is easily paid for unless you value your time at $0.01 per hour.

David.

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

david.prentice wrote:
Which is why you debug a project in the first place!

Hi David

Thanks for your reply -

Could I trouble you to explain what you mean by 'debug a project first'
(I worry that I am missing some vital step!)

I have done exactly this project on the ATMEGA16, and it works perfectly. Now when I try it on the Tiny5, I get unimpressive results!

The code itself is only a few lines:

while (1)
      {
         delay_ms(500);
         
         temp = read_adc(0);
         
         
         if (temp >= 50)
         { 
                PORTB.2 = 1;      //fan on
         }        
         
          if (temp <= 45)
         { 
                PORTB.2 = 0;      //fan off
         }         
         

      }
}

... and like I said, it has run perfectly on the MEGA16, so that's why I am thinking maybe a dead bug wiring problem (I can fix that with better PCB design), or some bug in Codevision (which is not under my control).

Thanks!
Pete

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

Quote:

Could I trouble you to explain what you mean by 'debug a project first'

He did not say "debug first", he said "debug in the first place". This ("in the first place") is a formulation in the English language meaning approximately "the actual reason for..." or perhaps "the primary reason for...".

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl wrote:

He did not say "debug first", he said "debug in the first place". This ("in the first place") is a formulation in the English language meaning approximately "the actual reason for..." or perhaps "the primary reason for...".

Well spotted!

And me a native English speaker, too! :oops:

Cheers
Pete

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

Quote:

And me a native English speaker, too!

Yikes! Didn't notice "Southhampton" but just assumed non-native-English-speaker.

Double-:oops: !

Sorry for the language rant!

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Quote:
... and like I said, it has run perfectly on the MEGA16, so that's why I am thinking maybe a dead bug wiring problem (I can fix that with better PCB design), or some bug in Codevision (which is not under my control).

You have been following my advice all along!

You could trace it with a cheapo JTAG-1 clone too.

It requires study of the appropriate differences between chips. I would guess that the ADC works a little differently. It may also be that the CodeWizard does not compose read_adc() quite correctly for a Tiny5.

You just follow the code line by line against the data sheet.

David.

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

Delay_ms. That code may be too large

Pete, what programer did you use?
Rep

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

If you are using V2.05.3 of CVAVR, you may also take a look at the ..\EXAMPLES\Tiny5_Level_Meter project.
It was written by Mr. Brian Hammill from Atmel and uses the ADC.

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

petenz123 wrote:
I have the LM35 temp sensor attached, and switching on an LED when it gets hot, it does some random switching on and off when it shouldn't, then eventually locks up!

I wonder if the wiring is picking up stray mains hum etc.?

Still, we've made a start!

Thanks
Pete

The LM35 NEEDS a cap on its Vout pin, if you don't have one now.

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1