Difference between revisions of "ATtiny13"

From ThorstensHome
Jump to: navigation, search
(Have)
 
(16 intermediate revisions by one user not shown)
Line 1: Line 1:
I have an ATtiny 13 programmable microprocessor. I wanted to use avrdude, the ATtiny13 and my ft232r chip. I am showing this for SUSE Linux 12.2, but other distributions may be similar:
+
This is an example how to upload a program to the ATtiny13 microprocessor so that it will act as a stand-alone computing device. An example is [http://www.elektronik-labor.de/Lernpakete/Kalender11/JingleBells.html playing jingle bells].
  
* I installed avrdude's dependencies:
+
= Have =
  yast -i bison
+
* an ATtiny13
  yast -i flex
+
* an ft232r chip
* I installed an avrdude update as described here: http://doswa.com/2010/08/24/avrdude-5-10-with-ftdi-bitbang.html
+
* a program for the ATtiny13, e.g. [[Compile_a_program_for_attiny13|beep.hex]]
* I inverted the FT232R's Bits as described under [[ftdi]].
+
* SUSE Linux 12.2. Other distributions may work similar, but you are on your own
* I connected MISO with RXD, SCK with TXD, MOSI with RTS and RES with DTR, then GND with GND and VCC with VCC. It will look like this:
+
 
 +
= Know =
 +
The ATtiny13 looks like this:
 +
            ------
 +
  PB0(MOSI)-|ATtiny|-GND
 +
  PB1(MISO)-| 13  |-
 +
  PB2 (SCK)-|      |-
 +
        VCC-|    o|-RES
 +
            ------
 +
 
 +
= Do =
 +
* install some [http://www.linuxintro.org/wiki/Dependencies dependencies] needed to [http://www.linuxintro.org/wiki/Build build] avrdude:
 +
  yast -i bison flex gcc make
 +
* install an avrdude update as described here: http://doswa.com/2010/08/24/avrdude-5-10-with-ftdi-bitbang.html
 +
* Connect MISO from the ATtiny 13 with RXD from the FT232R, and make more connections. In the end it must look like this:
 
   
 
   
 
       ------
 
       ------
Line 15: Line 29:
 
       ------
 
       ------
  
* I connected the FTDI chip with the computer
+
* connect the FTDI chip with the computer
* I unloaded the ftdi driver:
+
* unload the ftdi driver:
 
  rmmod ftdi_sio
 
  rmmod ftdi_sio
* I told avrdude to output the first byte
+
* test if avrdude works. Tell it to output the hfuse:
  tweedleburg:~/at/avrdude-5.10 # ./avrdude -cft232r -pt13 -P/dev/ttyUSB0 -U hfuse:r:-:h -B 1
+
  tweedleburg:~/at/avrdude-5.10 # ./avrdude <abbr title="Programmer is an ft232r chip">-cft232r</abbr> <abbr title="Controller is an ATtiny13">-pt13</abbr> <abbr title="Device name is /dev/ttyUSB0">-P/dev/ttyUSB0</abbr> <abbr title="U means memory operation">-U</abbr> hfuse:r:-:h -B 1
 
  avrdude: BitBang OK  
 
  avrdude: BitBang OK  
 
  avrdude: pin assign miso 1 sck 0 mosi 2 reset 4
 
  avrdude: pin assign miso 1 sck 0 mosi 2 reset 4
Line 42: Line 56:
 
  avrdude done.  Thank you.
 
  avrdude done.  Thank you.
  
Which is basically what I expected.
+
* seems to work. Now upload blink2.hex:
 
+
  tweedleburg:~/at/avrdude-5.10 # ./avrdude <abbr title="Programmer is an ft232r chip">-cft232r</abbr> <abbr title="Controller is an ATtiny13">-pt13</abbr> -P/dev/ttyUSB0 -U flash:w:blink2.hex -B 1
Wow, look at this:
+
  tweedleburg:~/at/avrdude-5.10 # ./avrdude -cft232r -pt13 -P/dev/ttyUSB0 -U flash:r:-:h -B 1
+
 
+
and this:
+
tweedleburg:~/at/avrdude-5.10 # ./avrdude -cft232r -pt13 -P/dev/ttyUSB0 -U flash:w:blink2.hex -B 1
+
  
 
Now draw RES and the thing will start blinking :)))
 
Now draw RES and the thing will start blinking :)))
  
  tweedleburg:~/at/avrdude-5.10 # ./avrdude -cft232r -pt13 -P/dev/ttyUSB0 -e -U flash:r:-:i -B 1
+
= Know-how =
 +
This does not fit into this article any more but I found it out:
 +
Read the flash:
 +
  tweedleburg:~/at/avrdude-5.10 # ./avrdude -cft232r -pt13 -P/dev/ttyUSB0 -U flash:r:-:h -B 1
  
 
= TroubleShooting =
 
= TroubleShooting =
Line 63: Line 75:
 
= See also =
 
= See also =
 
* [[programming electronics]]
 
* [[programming electronics]]
 +
* [[compile a program for attiny13]]
 
* http://www.bot-thoughts.com/2011/07/working-with-attiny13.html
 
* http://www.bot-thoughts.com/2011/07/working-with-attiny13.html
 
* http://doswa.com/2010/08/24/avrdude-5-10-with-ftdi-bitbang.html
 
* http://doswa.com/2010/08/24/avrdude-5-10-with-ftdi-bitbang.html
 +
* http://software.opensuse.org/package/cross-avr-gcc

Latest revision as of 18:30, 12 January 2013

This is an example how to upload a program to the ATtiny13 microprocessor so that it will act as a stand-alone computing device. An example is playing jingle bells.

Contents

Have

  • an ATtiny13
  • an ft232r chip
  • a program for the ATtiny13, e.g. beep.hex
  • SUSE Linux 12.2. Other distributions may work similar, but you are on your own

Know

The ATtiny13 looks like this:

            ------
 PB0(MOSI)-|ATtiny|-GND
 PB1(MISO)-|  13  |-
 PB2 (SCK)-|      |-
       VCC-|     o|-RES
            ------

Do

yast -i bison flex gcc make
      ------
 RTS-|ATtiny|-GND
 RXD-|  13  |-
 TXD-|      |-
 VCC-|     o|-DTR
      ------
  • connect the FTDI chip with the computer
  • unload the ftdi driver:
rmmod ftdi_sio
  • test if avrdude works. Tell it to output the hfuse:
tweedleburg:~/at/avrdude-5.10 # ./avrdude -cft232r -pt13 -P/dev/ttyUSB0 -U hfuse:r:-:h -B 1
avrdude: BitBang OK 
avrdude: pin assign miso 1 sck 0 mosi 2 reset 4
avrdude: drain OK 

ft245r:  bitclk 4800 -> ft baud 2400
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9007
avrdude: current erase-rewrite cycle count is -158 (if being tracked)
avrdude: reading hfuse memory:

Reading | ################################################## | 100% 0.01s

avrdude: writing output file "<stdout>"
0xeb

avrdude: safemode: Fuses OK

avrdude done.  Thank you.
  • seems to work. Now upload blink2.hex:
tweedleburg:~/at/avrdude-5.10 # ./avrdude -cft232r -pt13 -P/dev/ttyUSB0 -U flash:w:blink2.hex -B 1

Now draw RES and the thing will start blinking :)))

Know-how

This does not fit into this article any more but I found it out: Read the flash:

tweedleburg:~/at/avrdude-5.10 # ./avrdude -cft232r -pt13 -P/dev/ttyUSB0 -U flash:r:-:h -B 1

TroubleShooting

Symptom
avrdude: /dev/ttyUSB0 open failed 
Solution
Unload the driver blocking /dev/ttyUSB0, in my case:
modprobe -r ftdi_sio

See also