Good ATMega/ATTiny Tutorials

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
nphillips
 
Posts: 60
Joined: Wed Nov 05, 2008 8:50 pm

Good ATMega/ATTiny Tutorials

Post by nphillips »

<preface>
I'm trying to break away from the "limitations" of the Arduino, and want to start programming my ATMegas directly, without having to worry about a bootloader.

Since I have the equipment, I don't mind burning the bootloader, then programming the sketch, and ultimately attaching the chip to a non-Arduino PCB. But, I intend to distribute my code and schematics, and I don't want to unnecessarily alienate anyone by adding an additional layer of difficulty.

Plus, getting rid of the bootloader frees up a little extra space :)
</preface>
So, all of that to say: Does anyone know of a good series of tutorials that explain how and why the code works? I already have a marginal foundation in C/C++, so programming basics (conditional statements, variables, etc.) aren't necessary. I think what I'm (sort of) hung up on is how the various Ports work, and the bitwise operations to manipulate them. I'm a little confused by the fuses, too (pun wholeheartedly intended).

Information about Makefiles would be handy, too.

Now, before people haul off and tell me to google it: I have been. I still am. I've found a few tutorials that are okay. I want to see what all of you, personally, have found helpful. So please, don't copy/paste the first couple of search results here.

(as I've been writing this, I've been going through LadyAda's AVR tutorial...she linked to a GREAT bitwise lesson :D, but I wish she had the rest of the AVR sections completed...I love her style!)

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: Good ATMega/ATTiny Tutorials

Post by mtbf0 »

i started out reading the source code for the arduino. look under your installation directory in hardware/cores/arduino/. then get ahold of the mega168 datasheet. you won't get far without learning to read an avr datasheet and looking over the arduino code... well you know what it does and now you can see how it works.

User avatar
nphillips
 
Posts: 60
Joined: Wed Nov 05, 2008 8:50 pm

Re: Good ATMega/ATTiny Tutorials

Post by nphillips »

Good idea, mtbf0! I like it :D

Hopefully, the Arduino code is well commented...

User avatar
jimeli
 
Posts: 13
Joined: Sun Sep 06, 2009 11:32 am

Re: Good ATMega/ATTiny Tutorials

Post by jimeli »

While not necessarily ATmega/ATTiny specific, there are some good AVR tutorials on the avrfreaks forum.

vmsmith
 
Posts: 5
Joined: Tue Sep 08, 2009 12:14 am

Re: Good ATMega/ATTiny Tutorials

Post by vmsmith »

The library reference and a couple of example projects for avr-gcc is here:

http://www.nongnu.org/avr-libc/

Here is some info on using arduino without a bootloader:

http://arduino.cc/en/Hacking/Programmer

Other than that avrfreaks is good, and as others have mentioned, google the datasheets for whatever you want to use. Different AVRs have different capabilities, there are the AT90USB series chips with onboard USB, and appnotes for them, I've never used them, and I've heard it's not easy, but it's a lot cheaper than FTDI chips. There are tinys that have faster pwm for power supply stuff I think, some don't have a uart but have a USI instead, as far as I know all of them have multiple clock source options, which can save you a crystal, or for real time clock applications can allow you to use a 32.768 kHz crystal, etc. Getting away from arduino will give you more flexibility, but it will also make you reinvent the wheel a lot, you can also use the arduino libs without using the IDE, since it's just implemented in gcc anyway. I found a demo makefile for avr somewhere where you just change the MCU type and a couple other things and it works well, I'm not sure where it was though, it should be googleable, if I find it I'll post it.

vmsmith
 
Posts: 5
Joined: Tue Sep 08, 2009 12:14 am

Re: Good ATMega/ATTiny Tutorials

Post by vmsmith »

http://electrons.psychogenic.com/module ... p#makefile

Found it. BTW though, if you are mostly about saving space and not needing a bootloader uploading your sketches with a real programmer is very easy, it's just a couple of edits in the arduino preferences file and you can use any programmer supported by avrdude AFAIK. also

http://www.arduino.cc/en/Hacking/CommandLine

about using arduino without the IDE

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”