ATtiny13 and avr-gcc

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

first: yes, i've read the avr-libc FAQ, and i've read bruce lightner's web page, and i've downloaded his code, and i can build his test programs. so i believe that if i were doing a project with the ATtiny15, that i could code it in (a subset of) C.

but i'm not. :-)

i'm using the ATtiny13. before i attempt this work myself, has anyone else take bruce lightner's work, and extended it to support the ATtiny13? i suspect i could use it as-is if i were willing to give up using the SRAM, but that seems sort of silly, so i'll probably see what i can do to make it better. but i'd rather start where someone else left off, if possible...

thanks,
paul

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

one question for me, 'bruce lightner's work' what is that exactly? I never heard of him.

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

Not sure I get it, the tiny 13, like you write, has SRAM so there is no absolute need for special tricks, just program as for any other AVR. That said, given the small code space available, you should maybe avoid using library code. If you do, you can also, without much effort, make use of global register variables like, e.g.,

register uint8_t  tH asm("r2"); // High 8 bits of 16 bit timer

Just make sure all code is compiled seeing the global registers (everything in one file works for me since a program for a tiny 13 will be rather small anyway).

/Lars

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

thanks -- i guess i assumed, based on the current lack of compiler support for the tiny13, that there was more to it than that. but i'm the first to admit that the only other avr work i've done was on some of the bigger chips, and someone else set up the development environment before i took over.

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

> based on the current lack of compiler support for the tiny13

You must have a *very* old compiler then. Even the official GNU sources
used to support that device for more than a year, let alone the usual
"newdevice" patches.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

well, i'm certainly glad i asked my question, in that case! :-)

i started with cdk4avr 3.4.5. we had used cdk4avr on our previous avr project, so that's where i went when i knew we needed something newer. clearly it was to the wrong place. i guess i have some more reading to do. thanks...

paul

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

yeah I use the attiny13's all the time, its the tinys like the attiny12 you cannot program, due to lack of sram like lajon said.

image craft makes a c compiler for avrtinys, I have never used it but I think its purpose is for programing AVRS without SRAM, like the attiny12.

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

If starting a project, you might consider using the Tiny25 instead. Same price, more flash, more SRAM, more EEPROM, more toyz, drop-in upgrade to bigger models.

Lee

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

Quote:
If starting a project, you might consider using the Tiny25 instead.

thanks -- i hadn't noticed those. i'll mention that to the hw folks.

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

You can have a look at avr-libc's asmdemo example. As a side effect,
it (IMHO) impressively demonstrates the effort that is required on the
ATtiny13 using assembly tricks, compared to what can be done almost on
the fly on an ATtiny45 (where the resources needed would allow for an
ATtiny25 as well, it's only I just had the '45 around).

Actually, that's a side effect only, as I was really intenting to
write that as an asm demo (based on a real-world request from a web
forum), but then decided to rapidly prototype the functionality in C
on the ATtiny45, so to finally see the ATtiny13 version behaves the
same.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

I think an ATtiny13 can also be programmed, almost on the fly, in avr-gcc, although a few (mis)optimizations that have appeared in recent versions of the compiler have made that harder. (I would report them except the response I can expect is that I should use a larger part or a commercial compiler. I respect that.)

Some recent, non-trivial avr-gcc code I wrote for an ATtiny13 took 64 hours to create, test and put in service. I spent less than a day of that persuading avr-gcc to be reasonable, which wasn't bad. You do have to be pithy and get to the point, simply and without fluff, when you write your code. On the other hand, such code tends to work without trouble or fuss. Looking back, it also leaves you amused and in awe at just how much can be done in 'C' with fewer than 512 words of flash.

- John

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

> I would report them except the response I can expect
> is that I should use a larger part or a commercial compiler.

No, it does make sense to report this. Better use avr-gcc-list though
than this forum, or if you're sure, report a GCC bug.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

When I get a chance, I will try installing avr-gcc 4.1.1 (or whatever it is up to), reproducing my results and then asking if they are of interest on the avr-gcc-list.

- John