The new Raspberry Pi B Model B+ is here - Pick one up in the store and check our detailed guide!

TV-B-Gone with ATmega16L

by kscharf on Sun Dec 30, 2012 11:46 am

The attiny85 is well suited for the job, so why use an ATmega16L? Because I HAD some in the junk box (and they can store twice as many codes!)
Of course it isn't as simple as recompiling the code with MCU changed to atmega16 in the Makefile. Atmel moved the various timer control bits around and renamed registers between the two parts. However comparing the data sheets of the two parts showed that the job would be simple. I've posted the changes I made to main.c and main.h. Now just change the line containing "MCU = " in the Makefile and you're good. The IRLED moves to PB3 on the atmega16 since that's where the output compare bit in the timer hooks to. Otherwise the pin functions are the same (but on different pin numbers!). You could easily make the same sort of changes to use an atmega328 so that an Arduino could run the code (but you'd have to overwrite the bootloader).

Second thoughts:
The atmega16L is a 40 pin chip (available in smaller 44 pin TQFP packages) and has more than 8 times as many IO pins as the attiny85. It also has a hardware uart, so if you want to enable the debug code you should rewrite the serial output routines to use the actual uart. I will look at that later. The atmega168 family would make more sense as a substitute than the atmega16 / atmega164 family since the 40pin part is overkill. Again I used this part because I had one. I'm posting this to show how you can port a design so you can use a part you happen to have rather than buy one that you don't.

BTW, I haven't yet actually tried this but I have the breadboard wired up and will do so later today. I see no reason it won't work (baring a typo in my code) based on my experience working with the AVR family for the past few years. I'll report back later. Have fun!
Attachments
main.h
change cpu type
(1.19 KiB) Downloaded 102 times
main.c
Mods to main.c to use atmega16l
(16.39 KiB) Downloaded 106 times
User avatar
kscharf
 
Posts: 185
Joined: Wed Sep 10, 2008 9:29 am