USBTiny Infrared Receiver
ATtiny2313_large.jpg
usbtiny-pcb-miniusb.jpg

Goal

The goal of this project is to build the USBTiny Infrared receiver, and make it work with a Medion MD81299 remote control, and possibly other remote controls.

Bill of materials

  • 1 x 330 Ohm resistor
  • 1 x Atmel Tiny2313 Microcontroller
  • 1 x 1500 Ohm resistor
  • 2 x 68 Ohm resistor
  • 1 x 100 nano Farad condensator
  • 2 x 33 pico Farad condensator
  • 2 x Z3V6 Diode
  • 1 x LED
  • 1 x mini USB connector
  • 1 x 12 MHz Quartz clock
  • 1 x 2x3 Pins for the ISP
  • 1 x 1x4 Pins for the USB

Compilation

With avr-gcc 4.1.0

Compilation gives an error "Flash size limit exceeded by 10 bytes":

zoobab@gierek /home/zoobab/soft/usbtiny-1.4 [30]$ avr-gcc -v
Using built-in specs.
Target: avr
Configured with: ../build-tree/gcc-4.1.0/configure -v --enable-languages=c,c++ --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --disable-libssp --build=i486-linux-gnu --host=i486-linux-gnu --target=avr
Thread model: single
gcc version 4.1.0
zoobab@gierek /home/zoobab/soft/usbtiny-1.4 [31]$ make clean; make
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/spi'
rm -f main.elf *.o tags *.sch~ gschem.log
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/spi'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/ir'
rm -f main.elf *.o tags *.sch~ gschem.log
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/ir'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/util'
rm -f libusb.pyc libusb_wrap.c usbtiny.pyc
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/util'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/spi'
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/crc.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/int.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/usb.c
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c -o main.o main.c
avr-gcc -g -mmcu=attiny2313 -o main.elf crc.o int.o usb.o main.o
text: 2056, data: 2, bss: 60
ERROR: Flash size limit exceeded by 10 bytes.
make[1]: *** [main.hex] Error 1
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/spi'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/ir'
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/crc.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/int.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/usb.c
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c -o main.o main.c
avr-gcc -g -mmcu=attiny2313 -o main.elf crc.o int.o usb.o main.o
text: 2058, data: 4, bss: 85
ERROR: Flash size limit exceeded by 14 bytes.
make[1]: *** [main.hex] Error 1
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/ir'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/util'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/util'

With avr-gcc 4.3.2

Compilation gives an error "Flash size limit exceeded by 20 bytes":

zoobab@gierek /home/zoobab/soft/usbtiny-1.4 [42]$ avr-gcc -v
Using built-in specs.
Target: avr
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --disable-libssp --build=i486-linux-gnu --host=i486-linux-gnu --target=avr
Thread model: single
gcc version 4.3.2 (GCC) 
zoobab@gierek /home/zoobab/soft/usbtiny-1.4 [43]$ make clean; make
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/spi'
rm -f main.elf *.o tags *.sch~ gschem.log
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/spi'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/ir'
rm -f main.elf *.o tags *.sch~ gschem.log
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/ir'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/util'
rm -f libusb.pyc libusb_wrap.c usbtiny.pyc
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/util'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/spi'
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/crc.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/int.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/usb.c
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c -o main.o main.c
avr-gcc -g -mmcu=attiny2313 -o main.elf crc.o int.o usb.o main.o
text: 2002, data: 2, bss: 60
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/spi'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/ir'
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/crc.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/int.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/usb.c
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c -o main.o main.c
avr-gcc -g -mmcu=attiny2313 -o main.elf crc.o int.o usb.o main.o
text: 2064, data: 4, bss: 85
ERROR: Flash size limit exceeded by 20 bytes.
make[1]: *** [main.hex] Error 1
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/ir'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/util'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/util'

Remove the LCD support

By removing the LCD support in the file ir/main.c by putting the variable LCD_PRESENT to 0:

#define LCD_PRESENT     0       // set to 0 to remove LCD support

And then it saves some space:

zoobab@gierek /home/zoobab/soft/usbtiny-1.4 [125]$ make clean; make
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/spi'
rm -f main.elf *.o tags *.sch~ gschem.log
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/spi'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/ir'
rm -f main.elf *.o tags *.sch~ gschem.log
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/ir'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/util'
rm -f libusb.pyc libusb_wrap.c usbtiny.pyc
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/util'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/spi'
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/crc.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/int.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/usb.c
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c -o main.o main.c
avr-gcc -g -mmcu=attiny2313 -o main.elf crc.o int.o usb.o main.o
text: 2002, data: 2, bss: 60
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/spi'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/ir'
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/crc.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/int.S
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c ../usbtiny/usb.c
avr-gcc -Os -g -Wall -I. -I../usbtiny  -mmcu=attiny2313 -c -o main.o main.c
avr-gcc -g -mmcu=attiny2313 -o main.elf crc.o int.o usb.o main.o
text: 1872, data: 4, bss: 85
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/ir'
make[1]: Entering directory `/home/zoobab/soft/usbtiny-1.4/util'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/zoobab/soft/usbtiny-1.4/util'
zoobab@gierek /home/zoobab/soft/usbtiny-1.4 [126]$

Questions

  • Which files do I have to upload with avrdude? ir/main.hex
  • Is it possible to use an Arduino to reflash the chip as an ISP programmer or via MegaISP?
  • Is it possible to port the code to smaller chips, like ATTiny13 or ATTiny25?
    • AtTiny13: too small amount of flash (1K only)
    • AtTiny25: no input capture support

Links

Comments

Add a New Comment