Notes on the ATTiny 841
Working with the ATTiny841
Atmel released some new ATTinys in November 2013, essentially a refresh of the ATTiny 24/44/84. The new chips have quite a bit different, the highlights of which are (for me)
- Proper I2C rather than the godawful USI framework. The I2C is I2C slave only, and
TWI_slave_vectinterrupt which is on the ATTiny 828, rather than the
TWI_vectinterrupt which is on many of their other parts and which can serve as master or slave.
- The fuse bits are different - careful!
- The ADC differential channels are more flexible (the pins no longer have to be adjacent), and gain can be set to x1, x20 or x100 (the ATTiny84 only had x1 and x20
- The power consumption during sleep can be reduced
- Two full USARTs!
- Dedicated SPI hardware, again not using the USI from the ATTiny84
- Another 16 bit timer
- Internal 4.096 reference voltage as well as the 1.1 reference from the ATtiny84. However it's still ±10% which makes it not very useful for me
- The pullups on the input pins are not done with the DDR register, but with a new PUE register. It's possible to have then enabled even in output mode, which is a bit odd, but ties into another feature which is that when switching pins from input to output it's possible to set "make before break". In other words it's possible to switch the pin directly from input-pullup to output-low in one clock cycle without the pin floating. Handy for I2C, and it might explain why I could never get it to work properly with the older hardware...
- Two of the output pins can optionally be set to "high power", which means they can sink more current when set to low output. Pins are still limited to 40mA per pin, like the older chips, so I think this is primarily useful if you're running the chips at low voltage, eg 1.8V
Hurdle 1: The pin names in the spec doesn't match the AVR includes
This wasn't a hurdle exactly, but took me a few minutes to figure out the error wasn't
mine. Some of the registers described in the specification are spelled differently
to the code in
avr/iotn841.h - for instance, it's
DDRB0 rather than
DDB0. If your code isn't compiling, check that include for the definitive
Hurdle 2: ArduinoISP and avrdude can't program
Note: it's; 2016 and I am still seeing lots of interest in this section. The avrdude.conf file listed here is way out of date. The latest version of avrdude should work with no changes.
Those are the good bits. The bad bits are that I can't program it with my existing
ISP rig, which is
based on the ArduinoISP and avrdude. I attempted to do so with the mods to
(and available for download here - append this to
But no luck: the firmware would appear to write, but verification would always fail.
their own AVRISPmkii and Atmel Studio 6.1 for programming, so I ordered one.
Hurdle 3: Atmel Studio needs to upgrade the firmware on my AVRISp and that doesn't work either!
Reluctantly I fired up a Windows VM and installed Atmel Studio 6.1, along with the update for the GCC and studio available for download here. Starting Studio shows my AVRIspmkii detected, but the firmware (1.11) is too old and needs updating to 1.17.
This fails. And the procedure described by Atmel to recover fails too - the device will no longer communicate with Atmel Studio 6.1 at all. This is not uncommon apparently and I can still flash older versions of the firmware with Atmel Studio 4 and 5, just not 6. However I need the new firmware supplied with Atmel Studio 6 for the Attiny841! What to do?
Here was my solution.
- Copy the firmware files from
C:\Program Files\Atmel\Atmel Studio 6.1\tools\AVRISPmkIIto
C:\Program Files\Atmel\AVR Studio 5.0\tools\AVRISPmkII
- Short the reset pins as described here to reset the device
- Upgrade the firmware using Atmel Studio 5.0. It will use the firmware you copied from Studio 6.1 in the first step
Finally I have firmware 1.17 on the device. More to follow.
PostScript - Feb 2013
Not much more to say other than these chips are a welcome improvement over the Attiny84. The I2C is working flawlessly, the USART makes debugging a lot easier, and programming with avrdude and the AVRISPmkII is quick and works - I splashed out on a Tag Connect cable and with that connector on my boards, I can now flash about 10 a minute.