AVR.. Whats that then?

16 views
Skip to first unread message

Jamie

unread,
Nov 25, 2012, 4:38:20 PM11/25/12
to canterbury...@googlegroups.com
Howdi guys

Ok, so some of you may remember me last month (or beyond) I had bought me a arduino mega 2560. I'm not so proud to say it's not been used much (various reasons).

Anyway, upon my many read-ups on instructables looking at various things, I keep coming across this AVR business that seems to be related to arduino somehow.

Now, from what I can fathom, arduino is like a platform using atmel chips that can also be used by themselves without the rest of the arduino stuff - is that right? Can they still be programmed like arduinos? Reason I ask is that arduino seems convenient to program but it seems that you need to use a atmel chip on its own in your own circuits OR waste an entire arduino dedicated to it (expensive).

Thanks!

JD

Fred Barnes

unread,
Nov 25, 2012, 4:55:22 PM11/25/12
to Jamie, canterbury...@googlegroups.com

Hi JD,
Short answer, yes. Atmel have been producing these AVR chips for a long time
now. Indeed, I was happily programming AVRs for use in my own home-brew devices
long before the Arduino existed (http://frmb.org/hardware.html). The Arduino
provides a convenient hardware platform for tinkering, as it gives you the AVR
on a board with power connectors, crystal oscillator, USB/serial thingy, plastic
sockets to stick wires in, etc. *plus* the software environment that makes
the whole thing accessible. But, you can just as easily program an AVR chip
on its own, in whatever circuit you like -- all it needs it power and a crystal
basically (and some AVRs have their own internal oscillators, though these
tend to be slow). That's partly what makes them attractive for the Arduino --
hardly any external components needed.

Programming an AVR on its own is not a problem generally. Either build your
own serial or parallel programmer (as I've done in the past), repurpose an
existing Arduino for the same thing, or just (with DIL packaged AVRs) use the
Arduino as a programmer and carefully prise the AVR out of its socket for use
in your own projects [obviously this won't do for SMT!]. The *slight* caveat
is that the Arduino-provided AVRs will have the bootloader stuff on there
already; a blank AVR will not, and getting it on there will probably require
ISP/serial or parallel programming (which can be done by another AVR easily
enough). The Arduino site had instructions for a nice home-brew parallel-port
(bit-banged) programmer for AVRs, which has done me well on and off when
needed.

As far as software is concerned, yep, it's all the same stuff at the end of
the day. However, be slightly cautious of how your own circuits might differ
from the specific Arduino one (e.g. clock rate, what signal lines are connected
where, etc.). They are fairly robust though -- I've only cooked a handful of
AVRs over the last 15 years or so. The Arduino AVRs tend to be quite powerful
and capable; a lot of my home-brew stuff was made with a few-quid AT90S1200,
AT90S2400 and AT90S23213s. That said, buying breadboard, etc. isn't cheap
compared with the mass produced Arduino.


Cheers,

-- Fred

Jamie

unread,
Nov 25, 2012, 5:16:55 PM11/25/12
to canterbury...@googlegroups.com
Hi Fred

Now thats another thing I wanted to ask about.. (this may sound stupid).. What is the bootloader on these chips then?

Would I be right in thinking its basically doing a similar job to a PCs bios in setting things up ready to run?

JD

Fred Barnes

unread,
Nov 25, 2012, 5:36:38 PM11/25/12
to Jamie, canterbury...@googlegroups.com

Hi Jamie,

> Now thats another thing I wanted to ask about.. (this may sound stupid)..
> What is the bootloader on these chips then?
>
> Would I be right in thinking its basically doing a similar job to a PCs
> bios in setting things up ready to run?

Partly, but not entirely. Some variants of the AVR support the ability to
write to the FLASH memory from within program code. Normally this is considered
bad (self modifying code). However, the AVR allows this to be done by a
special 'bootloader' program, which lives somewhere else in the flash memory.
A fuse bit (IIRC) on the chip tells it to start executing at address zero
(normal behaviour [1] and where your compiled programs start from), or from
a much higher address (0x5000 or somesuch) which is where the 'bootloader'
lives. The bootloader is optional.

The purpose of the bootloader, with the Arduino, is to allow a user to upload
new code to the AVR over its serial line (USB to the user); normally code
programming is done by bit-banging on various ports (ISP, etc.), and you need
to use this technique to replace the bootloader itself, for instance (it can't
overwrite itself). If nothing happens on the serial port for a couple of
seconds, the bootloader program just transfers control to the user program.
For the Arduino, this bootloader pretends to be an STK-500 programmer or
similar -- the code is on the arduino site/repos, and is mostly straightforward.

[1] address zero is where the reset interrupt vector lives, which is just a
jump instruction to where your code actually starts.


On a related note, the AVR documentation available from Atmel is excellent
[modulo occasional errata]. -- and can probably explain this stuff much
better than myself :).


Cheers,

-- Fred

Justyn Butler

unread,
Nov 25, 2012, 6:27:34 PM11/25/12
to canterbury...@googlegroups.com
Hi Jamie,

I've got a spare AVR programmer lying around I could lend you for a bit if you need. It's this one: http://uk.farnell.com/atmel/atavrdragon/emulator-programmer-for-avr/dp/1455088

Doesn't come with any kind of connectors though, so you might find the other approaches Fred is talking about easier. Just let me know.

Best,
Justyn



--
You received this message because you are subscribed to the Google Groups "Canterbury Hackspace" group.
To post to this group, send email to canterbury...@googlegroups.com.
To unsubscribe from this group, send email to canterbury-hacks...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/canterbury-hackspace?hl=en.

Andrew Cassidy

unread,
Nov 25, 2012, 6:45:01 PM11/25/12
to canterbury...@googlegroups.com

I cheat, I have one arduino which I use as a programmer. First, I use the sketch that allows an arduino to act as a programmer to flash the bootloader onto an ATmega328P, then plug that chip into the arduino board to program. Once you're happy with the program just pull the chip out and solder your project up. Cost of the chips are ~£4 tops.

Reply all
Reply to author
Forward
0 new messages