Monday, February 25, 2013

ATtiny13V


Introduction

I bought some AVR microcontrollers a while ago, and while I still had the programmer out of its box since burning the ATmega328PUs I wanted to try to program the ATtiny13V. 

ATtiny13V

The ATtiny13V has:
"– Up to 20 MIPS Througput at 20 MHz
...
High Endurance Non-volatile Memory segments
– 1K Bytes of In-System Self-programmable Flash program memory
– 64 Bytes EEPROM
– 64 Bytes Internal SRAM
...
– On-chip Analog Comparator
...
• Operating Voltage:
– 1.8 - 5.5V for ATtiny13V" -
datasheet
So as you realize this microcontroller has very little memory and only 1KB of flash memory for your programs... I just got it because its cheap

First thing is to put it on a breadboard, since all my good ones are used in the trilateration project I use this one without any power rails.

ATtiny13V on breadboard
In order to connect it properly I need the datasheet. From that I can see the pinout enabling me to connect it to the programmer.

From the datasheet
So the programming adapter has these nice clearly labeled pinout. So this makes it easy to connect.

Sparkfun programming adapter pinout

To use the Arduino IDE to program the microcontroller we need an Arduino core for it.

A fast googleing lead me here: http://sourceforge.net/projects/ard-core13/

I downloaded the core13_017.zip unzipped it and placed it in "arduino-1.0.3\hardware\arduino\cores" restarted the IDE. Hm nothing I guess that is since it is not in the "arduino-1.0.3\hardware\arduino\boards.txt"

A little more googleing I find this http://arduino.cc/forum/index.php/topic,89781.0.html with some instructions and the thing to add to boards.txt
attiny13.name=Attiny 13A standalone
attiny13.upload.using=arduino:arduinoisp
attiny13.upload.maximum_size=1024
attiny13.upload.speed=19200
attiny13.bootloader.low_fuses=0x7B
attiny13.bootloader.high_fuses=0xFF
attiny13.bootloader.path=empty
attiny13.bootloader.file=empty
attiny13.bootloader.unlock_bits=0xFF
attiny13.bootloader.lock_bits=0xFF
attiny13.build.mcu=attiny13a
attiny13.build.f_cpu=128000
attiny13.build.core=core13
I restart the IDE again and now there is a "Attiny 13A standalone" under Tools/Board/

I tried to compile but get error messages that it does not find Arduino.h...

Changed the path of the core to arduino-1.0.3\hardware\arduino\cores\core13

Now I can compile, and changed the blink sketch so that pin 2 is the led pin...

The following taken from http://elabz.com/site/ shows the pins arduino names...

// ATMEL ATTINY13 / ARDUINO
//
//                         +-\/-+
// ADC0 (D 5) PB5 1| |8 Vcc
// ADC3 (D 3) PB3 2| |7 PB2 (D 2) ADC1
// ADC2 (D 4) PB4 3| |6 PB1 (D 1) PWM1
//                  GND 4| |5 PB0 (D 0) PWM0
//                         +----+

 When I try to upload to the controller I get the following error

avrdude: AVR Part "attiny13a" not found.
I changed in the boards.txt to
attiny13.build.mcu=attiny13
And restarted the IDE once more... and now I can compile and upload!

And behold!

Its looking like the timer is a bit wrong...



2 comments:

  1. The programmed fuses don't match your FCPU which is why the timer is so wrong.
    Note that the fuses in boards.txt are not programmed by default

    ReplyDelete