Here's a very informative posting from Craig L. discussing the port assignments of the ATMEL AVR...
I've been doing some analysis of the AVR Butterfly to see what
usefulness it might have as a robotics controller and thought I would
share the results with everyone. Everything I found I got from the
schematics in the butterfly's userguide I downloaded from Atmel.
It was a pretty brief look so if anyone finds any booboos let me know
and I will post a correction.
The big thing I was looking for was useful I/O pins, especially
I/O pins with analog to digital converters or pulse width modulation
channels.
Two 8-bit ports (with associated I/O pins) have connectors that we
can get at: port B and port D. Unfortunately, those ports are
shared with lots of other (but useful) stuff.
All four PWM channels are either shared with the navigation switch or
the piezo speaker. We are stuck with the speaker unless we disconnect
it. If we want to use the remaining PWM channels we just have to make
sure that no stupid humans fiddle with the button at the same time.
I would add an external switch that is monitored by the AVR through
one of the other usable ports and determines whether the motors are
enabled or not. You could end up with a short if the PWM channels are
in use and the user starts navigating with the switch.
The rest of port B is shared with the ISP port (which isn't a big
deal as long as we use those pins for output only), the navigation
switch or the dataflash.
Port D also has a connecter but those pins are shared with the LCD.
According to the schematic they are connected but I am not sure if the
LCD actually uses them. If they are used by the LCD then that entire
port will be unusable unless the LCD is disabled.
However, all is not lost. There are 4 pins on the JTAG port that are
useful (PF4-7). They are also ADC channels. That's cool.
The USI interface is also open for us (pe4-6). The UART pins,
however, have voltage converters attached going to j406. This
converts the serial voltages to the usual +12/-12 so we can hook it up
to a PC. If we want to run that to a low voltage serial device we
would need to keep the high voltages in mind.
The dataflash is tres cool. It's accessible through the SPI interface
(you must disable the AVR's SPI interface before you can do that but
getting back from that state could be challenging) and, of course,
you can get at it through the AVR. It has 4 megabits of data or 512
kliobytes. You could, say, have the butterfly record the temperature
every 60 seconds for an entire year. You will overwrite the
tunes that comes with the butterfly if you do that.
Overall, we don't have a huge number of ports to work with but with
clever design it can still be quite useful.
Here is a little table that shows the pin -> device/connector mappings.
Port refers to the AVR I/O port as described in the atmega169 docs.
Purpose is the pin's function. SegXX refers to the attached LCD segment.
Connector refers to the holes on the butterfly that we can solder headers
into.
Device refers to the device on the butterfly.
Note that some I/O pins have multiple uses. i.e. they are hooked up to
a port and a device.
There are 7 groups of locations where we can solder in headers. Below is
a little table that describes the header group (jXXXX) and what it does.
| CODE |
j400 port b j401 port d j402 jtag/adc j403 isp j404 battery clip j405 usi (universal serial interface) j406 uart *works through a voltage converter j407 voltage reader |
| CODE |
port purpose connector devices alternate connector -------------------------------------------------------------------------------- 01 LCDCAP 02 pe0 rxd/pcint0 J406* 03 pe1 txd/pcint1 J406* 04 pe2 xck/ain0/pcint2 nav switch 05 pe3 ain1/pcint3 nav switch 06 pe4 usck/scl/pcint4 j405 07 pe5 d1/sda/pcint5 j405 08 pe6 d0/pcint6 j405 09 pe7 clk0/pcint7 10 pb0 ss/pcint8 j400 flash 11 pb1 sck/pcint8 j400 flash j403-x-ISP 12 pb2 mosi/pcint9 j400 flash j403-x-ISP 13 pb3 miso/pcint10 j400 flash j403-x-ISP 14 pb4 oc0a/pcint12 j400 nav switch 15 pb5 oc1a/pcint13 j400 piezo 16 pb6 oc1b/pcint14 j400 nav switch |
| CODE |
port purpose connector devices alternate connector ------------------------------------------------------------------------------- 17 pb7 oca2/pcint15 j400 nav switch 18 pg3 t1/seg24 19 pg4 t0/seg23 20 reset 21 vcc 22 gnd 23 tosc2/xtal2 24 tosc1/xtal1 25 pd0 icp1/seg22 j401 26 pd1 int0/seg21 j401 27 pd2 seg20 j401 28 pd3 seg19 j401 29 pd4 seg18 j401 30 pd5 seg17 j401 31 pd6 seg16 j401 32 pd7 seg15 j401 |
| CODE |
port purpose connector devices alternate connector ------------------------------------------------------------------------------- 33 pg0 seg14 34 pg1 seg13 35 pc0 seg12 36 pc1 seg11 37 pc2 seg10 38 pc3 seg9 39 pc4 seg8 40 pc5 seg7 41 pc6 seg6 42 pc7 seg5 43 pg2 seg4 44 pa7 seg3 45 pa6 seg2 46 pa5 seg1 47 pa4 seg0 48 pa3 com3 |
| CODE |
port purpose connector devices alternate connector ------------------------------------------------------------------------------- 49 pa2 com2 50 pa1 com1 51 pa0 com0 52 vcc 53 gnd 54 pf7 adc7/td1 j402-9-jtag 55 pf6 adc6/td0 j402-3-jtag 56 pf5 adc5/tms j402-5-jtag 57 pf4 adc4/tck j402-1-jtag 58 pf3 adc3 59 pf2 adc2 light sensor 60 pf1 adc1 voltage reader 61 pf0 adc0 temperature 62 aref 63 gnd 64 avcc |