Connect with us

Can anyone recommend a good AVR book...

Discussion in 'Electronic Basics' started by [email protected], Sep 26, 2006.

Scroll to continue with content
  1. Guest

    .... for a beginner?

    And what's the difference, anyway, between the AVR and the ATxxxxxxxx
    series of chips?


  2. linnix

    linnix Guest

    AVR is so simple, you don't need a book. Just get a development kit
    and go through some examples on line and off line.
    Which AT? Generally speaking, ATtiny, ATmega and AT90 are similiar
  3. Guest

    Ah, so the AT90Sxxxx series is also an AVR... thought it was something
    completely different.

    So, about that book... ;-)

  4. Joerg

    Joerg Guest

    Hello Michael,
    Seriously, as Linnix wrote, you may not need one. I started with the TI
    MSP430, thought about buying a book but after taking a look at one I
    realized how fast some of the contents become obsolete. By the time it's
    printed there is a slew of new uC variations that are now used by everyone.

    Main things to get started: Learn the design environment, play around,
    try to make the blinky-LED work, try to change blink rates or pattern,
    load again and so on. Then study the family guide and the data sheet for
    a long, long time. After that you know all the assembler words the uC of
    choice understands and what they mean. Even if you never do assembler
    you need to become familiar with the peripherals on board and how they
    can affect or impair each other.

    If you really want a book recommendation I'd post again at
    comp.arch.embedded where among many uC experts there is also Ulf
    Samuelsson from Atmel. I am sure he'd know which books are good. Ulf is
    very responsive, I wish TI and others would participate as well.
  5. Guest

    Ah ok. (Actually until you mentioned it I didn't even notice linnix
    had replied inline to my first question. Sorry 'bout that, linnix.

    Was browsing over at and was getting worried about some of
    the comments the users said...

  6. Try I think there is a tutorial on there.......
  7. Rich Webb

    Rich Webb Guest

    The AT90-series were the (AFAIK) "original" processors in the AVR
    family. That family recently split into the ATmega-series with an
    enhanced instruction set (and, generally, larger processors) and the
    ATtiny family that is, well, tiny by comparison.

    There is some slop-over, with the relatively new AT90CAN128 chip being
    an almost identical twin to the ATmega128.

    All you really need to get started is, say, an ATmega8, an AVRISP
    programmer or the STK500 (if you don't have breadboards and bench power
    supplies handy), a copy of the free AVR Studio, and the device manual.
    The individual chapters in the manual do a good job of explaining how to
    tickle the various peripherals. The on-line help in AVR Studio handles
    the assembler and instruction set.

    Like Joerg, I typically approach a new processor with the embedded
    equivalent of "Hello, world!": get one pin to toggle at an intended rate
    using one of the chip's timers and an interrupt service routine. That's
    enough to validate that I grok the toolchain, can create a runnable
    image and get it loaded, and can sling around the necessary bits to
    handle ISRs and I/O. From there, the rest is just coding ...
  8. John B

    John B Guest

    You can also download a demo version of a C compiler from the
    Imagecraft website. It's free for 45 days and then becomes code limited
    to 8K which is still fine for the mega8.
  9. Guest

    The latest version of Atmel's AVR development environment works
    together with winavr. This means that you can write a C program and
    single-step it in the simulator, watching register, memory and i/o port

    One thing to watch out for if you use a serial in-circuit programmer -
    it is easy to lock yourself out of the device by setting the fuses

    In particular, setting the watchdog timer to "continuous" prevents
    reprogramming of the device or even the watchdog fuse!

  10. Simon Dice

    Simon Dice Guest

    I Agree with the others, but If you still want a reference book for
    programming in C the AVRs, I can recomend you this one:
    Embedded C Programming and the Atmel AVR
    Authors are Barnett, Cox &Ocull
    you can get it from B&N
  11. Guest

    Ok, thanks for the reference.

    I think I'll try and build my own programmer. I'll try the
    ATTINY11-6PC: $0.53 each at Mouser. What a deal! At this rate I can
    buy more than one, in case I burn it out.

    I've found some schematics for a programmer out here:

    I think the pinout is compatible with the AT90S2323, but I'll check the
    data sheets on the ATTINY11 to make sure...


    1) For the parallel port, is Pin 1 the pin on the upper-left looking
    at the Printer Port on the PC, or the upper-left looking at the Printer
    Cable (IOW, upper-right looking at the PC)?

    2) Let's say I want to make a simple AA battery tester (0 to 1.5 VDC
    range), and interface it to the PC via serial port. I know I'll need
    an ADC, and I can probably get away with using the one on the chip
    (comparator, right?). Anyone have any schematic for building such an
    AVR-to-Serial interface?

    fwiw, I went over to Borders last night, and even the PIC books didn't
    discuss in much detail how to interface with the PC. Just only how to
    interface the programmer with the PC. Sheesh.


  12. linnix

    linnix Guest

    Yes, a Max232

    Here is a battery charger with RS232 and LED read out. The LEDs are
    time multiplexed and maintain a rather constant brightness across
    voltage range of 2.4V to 2.8V (two NiMH cells). It's using the
    Atmega169, but should work with 165 (cheaper) as well. The basic
    components are:

    Max232 w/ 5 Cs
    Analog power filter (L, C and 2 R)

    SMPS is optional
    Analog multiplexer is not needed.
  13. Guest

    A Maxim part? From previous threads, I think I should stay away from

    Pretty neat! You used a drive bay, huh. I couldn't find the
    schematics on your site though. I'm mostly interested in the serial
    output circuitry. Is yours a bit-banger?

  14. Guest

    Ah, I think I'm starting to get it. Use a dedicated RS-232 chip. And
    here I was banging my head against a wall trying to figure out how to
    build my own.

    Well, surprisingly, Mouser actually seems to have a few MAXIM 232s in

    Hmm... if I'm going to use an output chip to control my computer
    interfaces, maybe I should just bite the bullet and look for a USB
    output chip... any suggestions? ;-)


  15. linnix

    linnix Guest

    OK, I should say TI, ST or Sipex RS232 driver chip.
    Yes, charging batteries while working on the PC, and logging the
    charge/discharge behaviours of the cells.
    I don't have one either. I went directly to layout from specs.
    No, the 165/169 has hardware UART on pin 2 (RX) and 3 (TX).

    AVR pin 2 to 232 pin 10 and AVR pin 3 to 232 pin 11
  16. linnix

    linnix Guest

    The AT90USB128 is almost pin compatible with the 165/169/329/649.
    Unfortunately, you have to rewire pin 2 to 5 for USB and RS232 to other
    pins. Actually, we simply bring out the pins to vias and wire them for
    either chip. This is a lousy design by Atmel. I wish there is a
    AT90USB128/Atmega649 combo.
  17. Guest

    Looks like the AT90USB128 is about $14 from Digikey. A (Texas
    Instruments!) MAX232 is about $0.90. For a beginner, I think I'll
    stick with RS-232. (Should be easier to write the software for the PC
    side too.)

    Thanks a bunch.

  18. linnix

    linnix Guest

    We won't be buying that much, but the qty 10K price is $2 to $3.
  19. Tim Auton

    Tim Auton Guest

    In wrote:
    The ATtiny11 has no RAM, only registers. C really needs some RAM for its
    stack, or you have to do some funky things to make it work at all. You
    can't have much fun with just 32 registers to store all your data (this
    paragraph contains more than 8x that much data). The small ones really
    are incredibly limited.

    Best advice for a hobbyist: Buy big. Considering the cost of shipping,
    it's a false economy to buy the really low-end chips. You'll end up
    making another order very soon when you find your first project is
    larger than you expect. What you though was a saving ends up as being
    more profit for FexEx.

    I'd suggest an ATmega8 (or two) and a few matching sockets - you can
    then swap the chip from project to project (no need for the sockets if
    you don't plan to solder stuff together yet, a breadboard is one big
    socket!). The ATmega8 has a UART, which means it has hardware to make
    talking to a PC's serial port easier[1]. It has a good amount of RAM
    and flash, which means you can use things like C's printf function to
    make life easier (printf and associated gubbins takes up around 2.5K of
    flash). It has multiple timers, plenty of pins, PWM and a bunch of other
    stuff you'll soon find you want.

    [snipped a question]
    You can use a comparator (gives a signal when one input has a higher
    voltage than the other) as an ADC, but you have to use it to measure the
    time it takes for the voltage you are measuring to charge up a capacitor
    to some reference voltage. You have to provide the capacitor, reference
    voltage, code to time it accurately, coded to turn that exponentially
    varying number into a linear voltage and make sure the current you take
    charging the capacitor doesn't affect what you're trying to measure
    (this method has a low input impedance - it puts a significant load on
    what you're measuring, changing it in the process). It takes two pins
    and you can only measure one voltage with your one comparator. This is
    not much fun, though it can shave a few cents of the price of your
    device, which might be worth it if you want to make a million of them. I
    doubt you want to make a million of them. Buy a chip with a proper ADC
    built-in; no external components, very little code, more accurate
    results, multiple inputs which take just 1 pin each and you can connect
    the pins directly to virtually anything without it affecting what you
    connect to (the ADC inputs have very high impedance). Don't connect the
    inputs to anything outside the AVR's supply range (0-5V probably, but
    you have some choice in the matter) though, or you'll fry it.

    For the battery, connect - to circuit ground, + to an ADC input on the
    AVR. The AVR's ADC can then measure the voltage with half a dozen lines
    of code. That wouldn't actually make for a great battery tester; there's
    more to testing batteries than just measuring the voltage, but that's
    another subject.
    Best to use the serial port, as that's by far the easiest. You might
    need a USB-serial converter if your PC doesn't have serial ports.
    Sending raw bytes is most efficient, but you'd then have to write
    software for the PC to decode those bytes. Much easier to just buy a
    nice big AVR and use printf to send ASCII text, at least at first. You
    can then use something like Hyperterminal on the PC and get text output
    on screen with minimum hassle. You can do clever, efficient protocols
    and squeeze them into the really cheap AVRs when you've learnt some

    [1] You will need a MAX232 or equivalent chip to convert the AVR's 0-5V
    serial port (UART) signals to the +/- 15V RS-232 signals a PC serial
    port expects - remember to buy the 4 capacitors such chips require too,
    if you don't have that kind of thing lying around. You need to think
    about the cable from the chip to the PC as well.

    If you haven't already, check out AVRFreaks. There is a lot more there
    than there may appear to be at first.

  20. Guest


    Thank you for taking the time to give very good advice to us newbies.
    I appreciate it.

    I think you're right. ATmega8. For about the price of a Six Dollar
    Burger at Carl's.

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day