Getting to know the AVR

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
Post Reply
ravyne
Posts: 59
Joined: Thu Sep 25, 2008 7:59 pm

Getting to know the AVR

Post by ravyne »

So, I'm very excited to get started with this Uzebox thing and eagerly awaiting Clay's production run to return and be made available.

I must, however, confess that I have little more than a passing familiarity with the AVR architecture and I wonder if you wise AVR veterans can point me to a really good book that I can delve into. The type of book I'm ideally looking for is the type that starts with the basics, but doesn't skimp on the details and isn't afraid to tread into advanced territory. If need be, this could be two or more books and cost is no concern -- to me, the right information is worth every penny. Particularly good web resources would also be much appreciated.

I'll share a brief word about my background and goals in order to better guide your recommendations -- I began programming in QBasic when I was 12 or so, then began writing "serious" applications (full-featured SNES-style RPG engines, Map Editors and a pair of Paint packages with full, home-grown GUIs) in it a couple years later and continuing through my high school years. When I graduated, I moved half way across the country to pursue a degree in computer science with a focus on video games, which I attained in 2005. I've since been working as a programmer or programmer-writer for both very small and very large companies. Today, I do most of my programming in C++ (or to a lesser extent, vanilla C) and I consider myself to be a very low-level-minded programmer -- I have no fear of twiddling bits, managing memory, or of using pointers in ways which make the average coder's head spin. Frankly, I like that type of work; I'm incredibly happy writing things like software rasterizers and it gives me a warm, fuzzy feeling when I'm able to exploit my knowledge of the cache architecture of a particular platform to gain performance. That is the type of programmer I am. I'm able to read and make sense of x86, z80, and Propeller assembly with a little doc assistance for the less familiar corners, as well as modify or write moderate sections of it. Really, I'm a software guy that longs to be more of a hardware guy and if I were able to afford to return to college I'd pursue an EE or CE degree.

Since Graphics are something of a particular interest of mine as I mentioned above, my intended goal for this whole Uzebox thing is to develop alternative graphics modes and even a ray caster to use in my own projects as well as to provide a platform which is practical for others to use and learn from. I think this is the spirit of what Uzebox is -- a bunch of folks pushing the limits at all different angles and sharing and feeding off what is gained, and I want to be a part of that not only as someone who reads and learns, but also as someone who learns and shares.
havok1919
Posts: 474
Joined: Thu Aug 28, 2008 9:44 pm
Location: Vancouver, WA
Contact:

Re: Getting to know the AVR

Post by havok1919 »

ravyne wrote:I must, however, confess that I have little more than a passing familiarity with the AVR architecture and I wonder if you wise AVR veterans can point me to a really good book that I can delve into. The type of book I'm ideally looking for is the type that starts with the basics, but doesn't skimp on the details and isn't afraid to tread into advanced territory. If need be, this could be two or more books and cost is no concern -- to me, the right information is worth every penny. Particularly good web resources would also be much appreciated.
So the book that seems to get the highest marks on the AVR is: "Embedded C Programming And The Atmel AVR" by Barnett, Cox, and O'Cull. It's good that cost is no concern since it's about $120. ;-)

"Programming and Customizing the AVR Microcontroller" by Gadre is cheap (like $30), but seems to get more harsh reviews. Beginners think it's OK, others consider it too high of fluff:content ratio.

I must confess that I own no books on the AVR myself. I got started on it back on the AT90S1200 when Atmel gave me a starter kit at my old job and just read the datasheets and app notes (after they made some!) to get a feel for things. That's not necessarily a bad route to take-- the AT90S1200 datasheet is only about ~70 pages, and the first ten of those give you the entire architecture and IO port space.

http://www.atmel.com/dyn/resources/prod ... OC0838.PDF

Essentially everything on the '1200 applies directly to the ATMega644. Right down to port names, bits, etc. There's a few little differences here and there (the '1200 had a hardware call stack and a finicky EEPROM), but I'd say that 95+% of it maps 1:1. It's a lot less intimidating than the ~300+ pages for the '644.

Atmel's website is pretty good now-- check out the appnotes in particular since they show code as well as techniques.

Also good to review is just the instruciton set:

http://www.atmel.com/dyn/resources/prod ... OC0856.PDF

One nice thing is that with Alec's kernel you can make perfectly good software with essentially no knowledge of the AVR at all for "application level" stuff. Like most good API's all the hardware is abstracted out of the equation and you're just making high level calls to do stuff. The kernel is super-stable; I don't think I've found a single bug. (Although I bug Alec with feature requests all the time.) :lol:

-Clay
ravyne
Posts: 59
Joined: Thu Sep 25, 2008 7:59 pm

Re: Getting to know the AVR

Post by ravyne »

Great resources Clay, thank you very much! I figured a good AVR text would be expensive, that's usually the case with niche material, especially when it's something people use professionally to make their living. The online resources you linked are great as well, they've already cleared up one question I had, which was whether or not the AVR had a means of accessing registers indirectly, which it does -- This is key for one of the video modes I've been dreaming up, so now I'll have to work out the specifics and see how many cycles I'm looking at exactly.

I'll have to find that formula in the other post and see what it would take to hit 256 pixels of horizontal resolution.

How many clocks/pixel did Uze get his sprite engine down to?
havok1919
Posts: 474
Joined: Thu Aug 28, 2008 9:44 pm
Location: Vancouver, WA
Contact:

Re: Getting to know the AVR

Post by havok1919 »

ravyne wrote:How many clocks/pixel did Uze get his sprite engine down to?
I do believe that the current implementation is 10 clocks per pixel with sprites and scrolling. Tiles-only mode was six, IIRC?

-Clay
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Getting to know the AVR

Post by uze6666 »

I wonder if you wise AVR veterans can point me to a really good book that I can delve into. [...] Particularly good web resources would also be much appreciated.
Personally, I learned everything I know on the AVR from Atmel's datasheets and application notes, which are really well written. Plus from a few projects online. http://www.atmel.com/products/AVR/
I do believe that the current implementation is 10 clocks per pixel with sprites and scrolling. Tiles-only mode was six, IIRC?
That's right.

Uze
Post Reply