OK, so you've got your new ATmega328P chips from a credible
distributor who won't sell you a housebrick with ATmega328P painted on
it. And they should be ATmega328P - with a P - by the way.
The easiest way to proceed, for an Arduino-compatible end result, is
to take some sort of Arduino-equivalent board with a 28-DIP socket,
Uno or whatever, remove the existing chip, put the new chip in (make
sure the orientation is right), connect an ISP programmer to the ISP
header (make sure the connector orientation is right) and program the
chip with an Arduino bootloader using the "burn bootloader" option in
the Arduino IDE. This is much easier for beginners than getting the
command-line parameters for avrdude right. The only thing you'll need
to check in the Arduino IDE is that you've selected the appropriate
programmer type that you're using. (What is it?) The target board type
can just be selected as Arduino Uno.
Using an Arduino-equivalent board to hold the chip during programming
means that all the wiring between the ISP programmer port and the chip
is known to be right, and you've got power and a decoupling capacitor
and a crystal provided, so you don't have to wire anything up, and
there's no uncertainty.
If you're using a USBASP compatible programmer, such as the
Freetronics one, then the first time you program virgin chips, because
of the way the oscillator fuse is set up, you'll need to plug in the
"Slow Clock" jumper on the programmer. This only has to be done once
the first time the chip is programmed, and for later iterations it
will be much faster.
If the chips fail to program, then you can report back more details
about what programmer you're using, and what happens, etc.
Now, re-flash the bootloader on all the chips you've already got.
Once the bootloader is programmed, you can test uploading code via the
USB serial port, using the pre-made Arduino-compatible target board
used to flash the bootloader. Again, this removes uncertainty in how
things are wired up.
If that works, put the chip on a breadboard, and connect +5V and
ground from an FTDI cable (or similar USB virtual serial port device)
to the AVR chip, and ensure that all the chip's Vcc and ground pins
are connected together, and put a 0.1uF decoupling capacitor between
one of the power pins and ground, close to the chip.
Connect TXD coming out of the FTDI cable to PD0 (RXD, pin 2) on the
chip, and connect RXD on the FTDI cable to PD1 (TXD, pin 3). (Check
these aren't swapped.) Put your 16 MHz crystal on the crystal pins
(ensure it's 16 MHz) and put the crystal load capacitors (say 18pF)
between each of the crystal pins and ground, next to the crystal. Put
a pull-up resistor (say 10k) between PC6 (reset, pin 1) and +5V, and
connect a 0.1uF capacitor in series between this pin and the nRTS pin
on the FTDI cable. If power is supplied externally, not from the FTDI
cable, then ensure that it's working and appropriately regulated.
Now, with the FTDI cable plugged into your PC, the virtual serial port
will be a different one than it was before, so select the right one,
and you can upload Arduino sketches.
If that works, if you want to, you can try connecting the ISP
programmer to the 6 appropriate pins on the AVR on the breadboard -
Vcc, ground, nRESET, MISO, MOSI, SCK - and burning the bootloader to a
chip on the breadboard.
Note that if your target AVR board has hardware attached to the AVR
then this may interfere with programming - if another UART device is
connected to the AVR this will need to be appropriately isolated, or
disconnected, when uploading Arduino sketches over the serial port. If
SPI peripheral devices or other hardware is attached to the AVR's SPI
pins, or reset pin, then this may interfere with programming if
they're keeping the pins driven or pulled to an inappropriate state
that the programmer can't overcome. If there's a problem with a
standard SPI peripheral and disconnecting it isn't practical, and the
nCS line is controlled by the AVR, putting pull-up resistors on the
nCS lines to keep them definitely de-asserted on the SPI bus during
AVR programming can fix that problem. So try disconnecting extra
hardware from your target board if practical - but if this is a
problem you will know about it, since programming will work fine using
an Arduino but fail on your target board.
> --
> You received this message because you are subscribed to the Google Groups
> "Connected Community HackerSpace" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
connected-community-h...@googlegroups.com.
> To post to this group, send email to
>
https://groups.google.com/d/msgid/connected-community-hackerspace/067ec829-ef8d-4ea3-a170-4fe119b8798a%40googlegroups.com.
This email is intended only for the personal and confidential use of
the human(s) named above. If intercepted by an extraterrestrial
civilization, all opinions expressed in this email are my own and do
not necessarily reflect the opinion of mankind as a whole.