Atmel put out some new, small microcontroller chips early this year, and we’re just now starting to think about how we’d use them. The ATtiny102 and ATtiny104 (datasheet) sell for about a buck (US) and come in manageable SOIC packages with eight and fourteen pins respectively. It’s a strange chip though, with capabilities that fit somewhere between the grain-of-rice-sized ATtiny10 and the hacker-staple ATtiny25-45-85 series.
The ATtiny104 has a bunch of pins for not much money. It’s got a real hardware USART, which none of the other low-end AVRs do, and it’s capable of SPI in master mode. It has only one counter, but it’s a 16-bit counter, and it’s got the full AVR 10-bit ADC instead of the ATtiny10’s limited 8-bit ADC. The biggest limitation, that it shares with the ATtiny10, is that it has only 1 KB of program flash memory and 32 bytes (!) of RAM. You’re probably going to want to program this beast in assembler.
Read on for more reviews, and check out [kodera2t]’s video review at the end.
Reviews
The first review comes courtesy of [Dan Watson] on his blog. He bought one of the Atmel Xplained 104 Nano evaluation boards back in March and put it through its paces. We don’t know how he got one for under $5 back then, but the kit seems available for under $10 from the usual suspects.
The Xplained kit is funny. It’s got a relatively powerful ATmega32u4 serving as an in-system programmer and USB-serial connector for the Tiny part. That’s funny because the programmer costs twice as much as the device under test.
[Dan] also presents a nice comparison chart of the small AVR parts. (Click to embiggen.)
[kodera2t] has been pushing the ATtiny series of chips to the max for a few months now, so we were stoked to see his review of the ATtiny102. Given the chip designation (T102-ES), he managed to get himself some engineering samples, which is extra cool-points, but shouldn’t discourage you because the parts are in stores now.
Instead of working with an evaluation board, [kodera2t] did everything from scratch. Maybe that’s why he emphasizes the new pinouts of the ATtiny102 parts. In particular, the GND pin is where the VCC pin is located on other ATtiny chips(!). It pays to read the datasheets. Although we’re grumpy and hate change, the new pinout is much more rational, with the VCC and GND pins together at the top of the chip, right where you want to add a decoupling capacitor anyway.
There’s one other minor gotcha if you’re used to working with the ATtiny parts. Because the ATtiny104 has fourteen pins, the GPIOs are split into two eight-bit banks: PORTA and PORTB. The ATtiny102 seems to be a chopped-down version of the 104, which means that even though it only has six GPIO pins, they’re still spread out across the two banks — three pins in each. If you’re accustomed to writing whole bytes at a time to GPIO output, this’ll force you to change your coding habits.
Uses
We find ourselves scratching our heads and asking what this chip is good for. The USART in a small and cheap package is a great feature. Something like the ATtiny14, with eleven or twelve free GPIO pins, fits a nice niche for very small projects. But we can’t quite get our heads around the 32 bytes of RAM. Whatever applications there are for the USART will have to reckon with a short receive buffer, for instance, and do its processing on the fly. C startup code alone costs a few hundred bytes, and with such limited RAM, we are guessing that coding assembler is the only reasonable option.
Of course, the hacker market was probably not even on Atmel’s radar when designing and marketing this chip. It must be good for some industrial use that we can’t quite figure out. What needs USART but doesn’t need much program or RAM? What uses can you think up for such a niche device?
“…. program this beast in assembler”
Beast??? More like a gnat.. Either way,highly optimized assembly would be the way to go.
More specifically, the assembler is the program that assembles assembly language into machine code. However, it is less commonly known as assembler language as well, though it grates on the nerves of those who actuallt program in assembly language. We know that you know what he meant, so pedantry is not essential to understanding here.
Oh, on another reading, you were questioning “beast”, not “assembler”. I see… Actually, severely limited resources can be more beastly and less civilized than larger devices. Gnats bite.
Seems the Attiny85 is A LOT BETTER and costs about the same. So why bother?
Or use an Attiny13A, nearly the same specs but for ~ 0,30€/$ on Ebay
You can try your luck on ebay. Ebay does sell a lot of good tech *things* mostly from China but chips are often fake. Even the chips in the left article picture look fake because of the color of the print but I suspect that that is because the color temperature when the pic as taken is low like 2700 – 3600 degrees Kelvin.
A lot of CPU’s and micro-controllers from ebay are chips that have had the tops ground off and reprinted with a part number of a better spec or faster chip. I don’t know if normal color vision people can see it but the color of the reprint is a white with a lower color temperature so it looks ever so slightly yellow’ish under a high color temperature white light. I use a 5700 degree Kelvin white light for inspection of parts.
The other give away is that the pins are often splayed further apart than normal. I have even had chips arrive with grinding oil still on them lol. One other give away is the depth of the orientation hole. It’s shallower from the grinding off of the original label.
It’s not a big issue for more experienced buyers as you can spot the fakes.
For people having Facebook, I made some nice comparison pictures of a bath of attinies that I purchased from EBay once.
https://www.facebook.com/photo.php?fbid=10200366004910217&set=a.1241521815665.28506.1757933986&type=3&theater
Ok, so… linking to a Facebook post didn’t work. ;)
Costs about the same? Well not anymore… it appears the new owners have new plans for AVR.
Hardware USART / SPI mastering in a tiny/cheap device? I’m asking.
32 bytes of RAM? Is this 1982 again?
Even the lowest end STM32 part (STM32F030F4) blows this thing out of the water: 16kB flash, 4kB RAM, 4 timers, 9 12-bit ADC, SPI, UART, I2C, interrupt on every single IO, and in TSSOP20 package as well. And cheaper too.
Why even bother.
Lower power? Better sleep modes? I dunno, just guessing. Could always be that hated thing, back-compatibility with existing code.
We’ll need some backup data on that. Last time I’ve checked, my design used a lot less power when I estimated power usage with an STM32F0 because that one woke up, had more computational power/MHz and a lower W/MHz, then went back to stop mode and used effectively less power than coin cell self-discharge. so, at the worst, it’d be a “emotional” tie, because both chips, when not doing something, are extremely power-saving. As soon as I needed to wake up the Attiny for regular maintenance, I couldn’t use its ultra-low power modes, and the SMT32F0 actually had a lower average power consumption.
DMA helps quite a bit in power management as the CPU clock doesn’t need to be fast or waste cycles polling or servicing peripheral IRQ. The flexible clocking let you shift clock speeds on the fly, shut off unused parts or runs lower clock speed for peripherals.
If you ever need to bit-bang on a chip because it doesn’t have the peripherals you need, all that power saving claims goes out the window.
Please provide more details, I am curious about the scenario.
My datasheet checks shows the tiny drawing 1.2mA@4MHz and the STM32F030F4 using 4.4mA@8MHz, needing about 2x the current per operation. In sleep the tiny has max 10uA@125C with running timer AND interrupts which would burn up to 32uA on the STM32.
Cycle count for a 8-bit chip is going to be a lot higher if you need it to operate outside of 8-bit math or need to shift bits or multiply. So “2x the current per operation” isn’t comparing the same thing.
Also most 8-bit microcontrollers, especially in Attiny or PIC10F/12F families have no hardware multiply capability. ARM Cortex-M0 has. So when you need to multiply any two numbers, STM32F030F4 will do that in one clock cycle. On the other hand if you are going to do some simple logic with no complex calculations, 8-bit micro will be as good as 32-bit one. It all depends on the usage…
Then there are ATmegas, which do have a hardware multiplier and are as efficient as Cortex-M0 regarding MIPS/MHz. Even when doing 32-bit math. Likely more efficient when doing 8-bit math, but I didn’t check this.
Also, AVRs are better integrated into gcc with the -mmcu parameter, have the much faster (compared to MBED) avr-libc and can run at 5 volts and provice 20 mA on a GPIO pin, allowing e.g. to directly drive LEDs. There are still a couple of good reasons to use AVRs.
There are 2 multiplier implementations for M0: single cycle vs 32 cycles. The STM32F0 datasheet doesn’t explicitly say about sngle cycle so chances are that it is 32 cycle. (Some other chips say it on page one under features.)
Not to sure about Atmega handling 32-bit as efficient as M0. Just having to burn 8 registers for operands sounds painful. If you have to shuffle operands for a 32-bit math library call, that’s going cost a lot of cycles vs a M0. Then add in the extra cycles of saving registers for the caller, it is just not going to be pretty.
If you have to go up the AVR family just to compete with M0, then there are a lot more competitive ARM chips at those price range.
The ATmega _is_ as fast per clock as an M0. That’s no theory, but running code. 3D printer Teacup firmware needs 304 clocks per motor step on ATmega vs. 296 clocks on M0 with 1-cycle multiplier.
Not sure how to explain this. I take the AVR has a lot more registers, 32 (8-bit) vs. just 8 (32-bit) on the M0. That’s an advantage for any non-32-bit section of the code (e.g. storing addresses). Data shuffling isn’t any faster on the M0. To load 32 bit = 4 bytes both chips need the same clock count. Also, neither needs a library call, both have a hardware multiplier. Count in that 32-cycle multiplier of some M0’s and you might end up faster on the ATmega.
That said, a Cortex-M3 or Cortex-M4 is indeed a lot faster, it gets away with 184 clocks. Due to more registers, I guess. And all Cortex’ can run at higher clock rates, of course.
With that type of thinking, we can’t have any new microcontrollers or new functionality. Thankfully that the market shows that 32-bit at close to 8-bit price range with more speed, more powerful peripherals are getting market shares.
Well this AVR series is almost as old as PIC’s but they still have some avantages or people wouldn’t keep buying them.
STM32 goes up to 32kB or 128kB SRAM from memory so you would be wasting development time by using it in a microwave control panel.
If you are only interested in the peripherals & RAM offered by the bigger chips (STM32) then this chip is not for you. As Greenaum says, low power is probably the biggest driver, perhaps the only driver. CR2032 for ten years type stuff. I don’t think your STM32 is going to do that.
Not too sure about back-compatibility though, would you not just keep buying/producing/cloning the chip you are trying to replace?
Besides, TSSOPs are for babies – go die… as in die bonding…
And the fact that an STM32F030F4P6 costs about half a buck.
32 Bytes.. I used to dream of having 32 Bytes.. Luxury!
My first programs run on what was essentially a programmable calculator and it had 16 bytes of memory and half of that was for the digit display.
2X3mm package w/ two PWM and USART? Serial control for a pair of servos?
With 5 channel ADC? A serial 5 channel ADC for remote applications?
I know, this isn’t likely the best device for either of these applications, but you asked what it is good for. If I was familiar with the architecture, and needed features like these, I might go for it due to ease of implementation, even if, objectively, the application might have a better fit. It isn’t about the best, it is about what gets the job done economically in an a timely manner.
assembly, not assembler..
You’d be surprised what you can do in 32B of ram. For instance I’ve written a switch statement based quadrature encoder… than only uses 10B of ram + whatever is used at run time.
You might be interested in this quadrature decoding code that I wrote for the tiny 104 — it uses one byte of SRAM for the state history, and works great for me:
https://gist.github.com/paulrpotts/3cea24b7e003fe00c63ff467a6f567ff
I just looked at my code just now and eliminated an extra byte so I’m down to 9 global bytes… also I’m using the Arduino libraries which use 4 bytes doing nothing but looping…
Are you just using avr-size to get the sram usage?
I’m using whatever AtmelStudio uses under the hood to report SRAM usage. I’m not sure what that is. If I look at the Output Files under Solution Explorer, I can right-click on one of the generated files, like the .elf or .hex, and invoke “Properties,” and it will show me the RAM size. Also I can look at the generated assembly language and see where it uses registers as opposed to SRAM locations.
Thats good to know that that functionality exists if I ever need to use it!
32 bytes isn’t so bad. PIC 8-bit baseline chips have as low as 16 bytes of RAM.
Without USB it seems a bit odd, though. I could see this being used in, say, an optical mouse or something… could even do PS/2 comms using the USART… but who would buy a PS/2 mouse these days?
The choice to use both PORTA and PORTB in the 8-pin chip is boneheaded, though. PORTA should be the same on both, and PORTB should be available only in 104 and contain just the additional pins.
Well if your going to code in Assembly then it makes little difference. What application would have ALL the GPIO’s dedicated to the same function, you would expect there to be at least two external function and in that way it is easier to code for in Assembly – less read/AND bit mask/OR bit set/write activity.
Uh, USB with 1k of flash and 32B of RAM? Ain’t happening.
These are chips pretty much designed for applications where one would otherwise use a bit of discrete logic or something like 555 timer. The timer is cheaper, but less flexible and needs more components around it. So something like a PWM light dimmer or a pushbutton controlled on/off circuit would be a typical application of something like this.
On the other hand, there are cheaper micros for such applications. Atmel sucks on prices again, as always.
Oh, just what I’m waiting for then, a microprocessor controlled toaster so I can have 255 digital settings = warm bread, nearly right, and 253 shades of black.
ROFl LMAO … made my day – toasters … made by Bastards INC. lol
Ain’t happening, you say? Sorry: https://cpldcpu.wordpress.com/2014/03/19/%C2%B5-wire-usb-on-an-attiny-10/
PS/2 is still used on servers and industrial stuff. I see this being used on things like a toaster oven or devices like that. Maybe even some small toys.
Something that small might be used as some simple control logic for small appliances. [Dave Jones] from EEVBlog once had shown insides of electric toothbrush that used 4-bit micro that had, IIRC, 16 words of RAM…
What did it use that for, battery charge controller?
It was surprisingly sophisticated. There was a lot of motor control and it would shut down if the current draw was too high (eg, you jammed it against your teeth). Also there was inductive charge control IIRC
I think they or a large customer used to use the Attiny chips for standalone capsense.
For some tasks the 32 registers in a Tiny13 where enough.
Wait, where did half of the register file go? This 102 part goes from R16 to R31.
Yes, the “Reduced Core TinyAVR” chips (4/5/9/10 and I guess these ones) ditch the first half of the registers.
Isn’t R0 the index to indexed address other register?
Not quite grokking what you are asking, but yes I also thought it weird that they started the registers from R16, there is no R0..15 on a reduced core TinyAVR. Atmel claims (Tiny 4/5/9/10 Datasheet Page 17) that this is “for reasons of compatability”.
Instructions that load or manipulate a constant directly into a register only work on R31-R16. LDI for instance does not work on registers <R16. The register asymmetry is annoying a hell sometimes.
Probably what they meant by compatible.
Async serial to SPI adapter maybe? Some sort of simple async front-end or process logging perhaps?
An ASCII async serial ADC fits the specs, certainly.
Could be useful as an LED flasher. /s
Actually, is it cheaper than a 7 segment BCD display controller now?
PIC24F04KA around a buck and 23.55 X the power of the Atmel
Sam d09. as cheap, same package. Lots more eveything inside… like 32 bit, 48 MHz 3 serial ports etc etc.
Agree. Samd09 is the dogs. Used in a project at work and surprised it hasn’t gained more traction with hobbyists given its peripherals, size and price – you can have all three!
It is a nice chip, but lazy hobbyists these days aren’t interested in a chip unless there are already libraries to help them. The hard core ones would have to be there first to write/port code.
I guess, part of the problem is availability for hobbyists. I live in Russia and it’s really hard to find any ATSAMs in retail. And if you do, the price is not reasonable. Chinese shops on eBay/Aliexpress also rarely sell these chips.
I guess, part of the problem is availability for hobbyists. I live in Russia and it’s really hard to find any ATSAMs in retail. And if you do, the price is not reasonable. Chinese shops on eBay/Aliexpress also rarely sell these chips.
Ima write to intel, ask them to do an embedded i7 with 2 bit external bus, 1KB ROM and 64 bytes of RAM just to troll geeks.
Change the ROM to WOM (write only memory) and i’m in.
Is this a joke from Atmel…? No DIP, or if going SMD you get an STM32 for the same price. A Skoda or Volvo for the same price…which one to chose?
Skoda
beefed up 555 time is all I would get out of it.
lol, this thing has lots of ADC so you could add some capacitors and code it to be a 555.
It’s odd, once you have a design adding RAM should not be hard, so I guess it just had too little space in the square of silicon to add more than a few bytes.
I wonder if someone decapped one so we can check.
But even if so, could they not have added a micron extra on the side for some more RAM?
I thought I read somewhere that the new owners of Atmel are moving to a higher nano-meter process for these chips so perhaps they want to fit it all on the same sized die.
There is always a sweet spot between manufacturing process and die size. Sometime it’s cheaper to stay on higher node than going on smaller ones.
All these comments go for the obvious limits, but I’d like to know WHY do they make this? Why the limits? What is the purpose really? They only mention it’s good for low power, but i can’t imagine that’s the whole story.
“none of the other low-end AVRs [have a HW UART]”: attinyx313 has HW uart; attinyx41 and attiny1634 have TWO hardware uarts (and 2k/4k/8k/16k of flash.) I guess with the recent price increases, they’re all in the $2 range instead of $1, though. (I got MY 1634s for less than $1. To play with (doesn’t mean much if you’re planning a product.)
1k of flash and 32 Bytes RAM are not much, but it’s still enough to do USB and drive a WS2812: https://cpldcpu.wordpress.com/2014/03/19/%C2%B5-wire-usb-on-an-attiny-10/
wow!
I wrote a little code where you can control up to 10 x WS2812 LEDs via Uart.
https://www.mikrocontroller.net/topic/401424#new
“C startup code costs a few hundred bytes of RAM”?
Not really. Sizes of a temperature controller using V-USB(!) on an ATtiny2313:
Program: 2046 bytes (99.9% Full)
Data: 56 bytes (43.8% Full)
It’s written in plain C and certainly does start up. Project page: http://reprap-diy.com/istatrol
I’m confused, but also not familiar with microcontrollers anyway.
32 bytes of RAM, 1K ROM? Isn’t that a bit big for a USART connected sensor node?
Or a SPI-connected USART perhaps! That would require minimal resources and can be handy for systems that need one more serial port and has a spare interrupt and select pin leftover ;)
I will just leave this $0.61 cortex-m0 in the same package here:
http://www.mouser.com/ProductDetail/Cypress-Semiconductor/CY8C4013SXI-400/?qs=sGAEpiMZZMsrb0xF%2fYczN9vL2PZOgvCE%2fv1S2OEw2hKHeu6Pq6cAwQ%3d%3d
I had those parts for a couple of months now and started to work on a serial bootloader:
https://cpldcpu.wordpress.com/2016/05/21/gluon-developing-a-bootloader-for-the-attiny104/
It’s far from complete, though.
I was a bit put back by the lukewarm reception of these devices, as also evident in the comments above. Unfortunately it is true – there are plenty of other options in the same form factor that are cheaper, more convenient, more powerful and potentially less energy consuming.
I would like to have an ATtiny10 with self-programming abilities, though.
Actually made a bootloader that was ready for launch of the device, if you need some pointers. Can be found here:
https://spaces.atmel.com/gf/project/tinybooty/
There was also made an app note based on that bootloader at a later time.
This for the info, very nice. You started from scratch with assembler, which was probably more efficient than cutting a C-based bootloader down :)
I found the application note.
Does Atmel spaces seriously require me to sign up to download open source projects? That place seems to be tumble-weed territory. Probably Atmel should just use Github, like the other companies?
Can you link to any articles on cpldcpu that are about cpu done in cpld? I am curious and the search doesn’t work for these tags because they’re apart of the page titles so it returns *everything*.
Confusingly, the cpu is here:
https://github.com/cpldcpu/MCPU
Thanks, very interesting read. I still have some of those MACH CPLDs here. Ones that were sold under the Vantis brand. I also have about 100 XC9536XL’s
I got an ATtiny10 programmed and working with this Xnano board :) from Atmel Studio 7 as mEDBG :)
I have been programming this device (the 104 version) and I’m surprised by what I can do with 32 bytes of SRAM, in C, using Atmel Studio (which uses gcc). When configured for this chip, the compiler generates no regular C runtime code at all. It will freely put locals in registers.
I can read an encoder and use it to encode a 16-bit value, using only 3 bytes of SRAM, and in the same program bit-bang SPI to a serial EEPROM chip using only a few more bytes. With the GPIOs I can drive a couple of LEDs and give them some flashing and timeout behavior using another couple of bytes. So for the cost of maybe half that SRAM I can implement an encoder driving an ADC with LEDs that flash to indicate that the user has hit the top or bottom of the available voltage range.
I’ve also got one of them doing simple control of an iTLA (laser source) over serial.
It’s never going to run a web server or parse JSON, or even run an RTOS, but this is perfect for some limited development tasks. And because they are so cheap and simple, it has brought back some old-school hacking fun to my development work. Not everything needs an ARM core and a megabyte of EEPROM…
Xatax can you write how you do this?
Interesting comments and thanks for post