Serial communication with ATtiny uC's

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

Please forgive the noobish question, but I'm new to microcontrollers (just started learning as much as possible over the last 2-3 weeks).

My question:
From what I've found, the AVR ATtiny series uC's do not feature integrated UART controllers. I've seen some examples for serial communication using the older 8051/AT89C2051 modules, but haven't found much on using an AVR chip without the onboard UART. I imagine it can be done, but it would have to be code driven, correct?

The reason I'm looking at the ATtiny series is cost. I'm trying to integrate a microcontroller into a heater/thermostat circuit that needs to communicate serially to a LED driver. I need to choose a uC I can purchase in low volumes for $2-3 per unit that will fit this purpose.

Does anyone have a link with example code/schematic(s), or can anyone provide any input?

Thanks in advance!

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

Quote:

1) From what I've found, the AVR ATtiny series uC's do not feature integrated UART controllers. ...
2) ... using an AVR chip without the onboard UART. I imagine it can be done, but it would have to be code driven, correct?
3)... The reason I'm looking at the ATtiny series is cost. ... I need to choose a uC I can purchase in low volumes for $2-3 per unit that will fit this purpose.

1) Not entirely true. The ATTiny2313 has a UART subsystem, pretty much identical to other AVRs.
2) There have been quite a few discussions on this on the Forum. Try searches for "software UART" and similar. Atmel has an app note on it. Also check the User Projects section of the Web site.
3) Not entirely true, either, if "value" is part of the cost. For example, the ATTiny2313 is US$1.25 in qty. 100 from DigiKey (including the hardware UART). The ATMega48 is US$1.50 in qty. 100. Both are well under your $2 target, even in qty. 25. The Mega48 has more flash, more EEPROM, more SRAM, and more subsystems including A/D. If you don't need any of those resources then the '2313 is somewhat cheaper. If you do need some of those resources (e.g., A/D converter) then the Mega48 would probably be a better "value" than, say, adding an external A/D converter.

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.

Last Edited: Tue. Mar 1, 2005 - 10:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lee - your entire post was helpful, but in particular, #3 was very helpful.

You saved me a ridiculous amount of datasheet rummaging - the Mega48 seems to be the uC of choice, then.

Last Edited: Sun. Sep 23, 2007 - 04:03 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

You saved me a rediculous amount of datasheet rummaging ...

Have you tried the "Devices" tab on this Web site, with the parametric display?

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

I did, in fact - embarrassingly, I must not have scrolled down to see the 2313. :mrgreen: :oops:

Regards!

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

The cheapest AVR is the Tiny11 (25c in quantity). It doesn't have a hardware UART, but a bit-banged software UART works OK, if it has a crystal clock, leaving two I/O pins. It might do what you want, very cheaply.

Leon

Leon Heller G1HSM

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

Damm

Who wants to sell 20 pcs M48 to me for US$30 :-)

/Bingo

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

Can you use clocked serial TTL instead?
Much less mess than a software uart, I've implemented this in the 2343 and a few others without problems. Let the host system be the slave though, otherwise it's complicated.

KC6ETE Dave's Engineering Page: http://www.dvanhorn.org
Microcontroller Consultant specializing in Atmel AVR.
Analog and Digital hardware design.
Custom Palm Applications.

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

Dave, can you elaborate on how I would go about doing that? I'm quite new to this....

I now found my one drawback to the Mega48 - the fact that the STK500 doesn't support it. :(

EDIT: It appears I'm going to have to implement software UART anyway, seeing as how I need to communicate serially with two devices.

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

IIRC, Software UART is described in AVR304 and AVR305. One of them uses interrupts, the other doesn't.

It might be cheaper and/or easier to use two Tiny11's, a software UART on each one.

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

Here is a demonstration program that implements a full-duplex software UART for the AVR. It can send and receive data at the same time. It is fully interrupt driven. There should be enough comments and documentation to be able to study it.
I wrote it for MIDI, which is 31250 baud. It can be adapted for RS232 standard baud rates by changing the value that gets loaded into the timer. The byte that arrives into the softUART is displayed on a pair of 7-segment LEDs that are driven by an 8-bit output port. It was written for the Tiny26 but should work with some modification with any AVR that has SRAM for a stack (all except the 1200 and the Tiny11).

Attachment(s): 

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

@bingo:

Quote:
Damm - Who wants to sell 20 pcs M48 to me for US$30

$1.50 is the 100-up price, but you can get 25 of them for $40 US. What do they cost in DK?

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

All prices in US$

At ELFA in Denmark i have to pay :

M48-DIL@14 pcs (a tube) = 2.90
M48-DIL@1 pcs = 3.74

M88-DIL@14pcs (a tube) = 3.72
M88-DIL@1 pcs = 4.65

To those prices come an additional 25% in Sales Tax (and i can't deduct that , as i'm private not a copmany)

I can get them @ e-bay in germany

M48-DIL@1 pcs = 2.61
M88-DIL@1 pcs = 3.91
M168-DIL@1 pcs = 7.04

I would expect that Sales Tax are allready paid in Germany on the e-bay prices.

And the Danish government wonders why we don't buy @home

/Bingo

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

SteveN wrote:
If you are, you can't go by that. Atmel doesn't keep the printed (and maybe even their PDF) manuals updated. You have to use the Help section of Studio.
I was - and I started wondering about that after I had posted that, so I went looking on Atmel's site under the Mega 48, and of course it says that the DIP version is supported for the STK500, so there we go.

I just ordered the 500 and 4 Mega48's from Digi-Key around 6:00PM EST last night, and they already had it shipped yesterday (!!) It should be here around the 9th, so I'll start playing around/prototyping then.

Thanks for everyone's help!