Using the 1284p/664p (IDE, bread board and boot loaders)

What you will need (in order to use the 664p/1284p in a breadboard):

AT Mega 644p/1284p IC (with boot loader) 16/20MHz crystal 2 x 22pF capacitors 10K resistor Breadboard LEDs 220 ohm resistors Arduino duemilanove board with the 328 IC removed!

What you will need (in order to install boot loader)

AT Mega 664p/1284p IC USB tiny (works for REprogramming boot loader - will let you know if works on fresh IC later) AVR ISP mkII ICSP programmer (better option) AVR studio v5

Setting up the 1284p (or 664p) on a breadboard.

1 ) pin 9 to 5V via a 10K resistor 2 ) pin 10 to 5V 3 ) pin 11 to GND 4 ) pin 12 to GND via a 22pF capacitor 5 ) pin 13 to GND via a 22pF capacitor 6 ) place 16/20MHz crystal between pins 12 & 13 7 ) pin 14 to arduino duemilanove board pin RX 8 ) pin 15 to arduino duemilanove board pin TX 9 ) pin 30 to 5V 10 ) pin 31 to GND 11 ) pin 6 to anode of an LED with cathode to GND via a 220ohm resistor (for the blink program) 12 ) connect GND and 5V of the arduino board to the bread board. 13 ) connect the Arduino board to your computer using a standard USB cable.

Modifications to the IDE on Arduino:

1) Download the ZIP file containing the additional files. 2) Install the Arduino code as per instructions on their site. 3) Locate the file “boards.txt” which will be located inside the Arduino program folder inside “Resources/Java/Hardware/Arduino”. Now copy the following text as it is and place it into the boards.txt file as the other ICs appear.

##############################################################

ADABoot1284Pst.name=ATmega1284p stk500v2 loader w/20Mhz 
ADABoot1284Pst.upload.protocol=stk500v2
ADABoot1284Pst.upload.maximum_size=126976
ADABoot1284Pst.upload.speed=115200
ADABoot1284Pst.bootloader.low_fuses=0xF7
ADABoot1284Pst.bootloader.high_fuses=0xD8
ADABoot1284Pst.bootloader.extended_fuses=0xFD
ADABoot1284Pst.bootloader.path=stk500v2
ADABoot1284Pst.bootloader.file=stk500boot_v2_mega1284p_20.hex
ADABoot1284Pst.bootloader.unlock_bits=0x3F
ADABoot1284Pst.bootloader.lock_bits=0x0F
ADABoot1284Pst.build.mcu=atmega1284p
ADABoot1284Pst.build.f_cpu=20000000L
ADABoot1284Pst.build.core=arduino
ADABoot1284Pst.verbose=true

##############################################################

atmega1284p.name=ATmega 1284p (20MHz)

atmega1284p.upload.protocol=stk500
atmega1284p.upload.maximum_size=131072
atmega1284p.upload.speed=38400

atmega1284p.bootloader.low_fuses=0xFF
atmega1284p.bootloader.high_fuses=0xDC
atmega1284p.bootloader.extended_fuses=0xFD
atmega1284p.bootloader.path=atmega
atmega1284p.bootloader.file=atmega1284p_20.hex
atmega1284p.bootloader.unlock_bits=0x3F
atmega1284p.bootloader.lock_bits=0x0F

atmega1284p.build.mcu=atmega1284p

atmega1284p.build.f_cpu=20000000L
atmega1284p.build.core=arduino

##############################################################

atmega1284p16.name=ATmega 1284p (16MHz)

atmega1284p16.upload.protocol=stk500
atmega1284p16.upload.maximum_size=131072
atmega1284p16.upload.speed=38400

atmega1284p16.bootloader.low_fuses=0xFF
atmega1284p16.bootloader.high_fuses=0xDC
atmega1284p16.bootloader.extended_fuses=0xFD
atmega1284p16.bootloader.path=atmega
atmega1284p16.bootloader.file=atmega1284p_16.hex
atmega1284p16.bootloader.unlock_bits=0x3F
atmega1284p16.bootloader.lock_bits=0x0F

atmega1284p16.build.mcu=atmega1284p

atmega1284p16.build.f_cpu=16000000L
atmega1284p16.build.core=arduino

##############################################################

atmega664p.name=ATmega 664p (16MHz)

atmega664p.upload.protocol=stk500
atmega664p.upload.maximum_size=131072
atmega664p.upload.speed=38400

atmega664p.bootloader.low_fuses=0xFF
atmega664p.bootloader.high_fuses=0xDC
atmega664p.bootloader.extended_fuses=0xFD
atmega664p.bootloader.path=atmega
atmega664p.bootloader.file=atmega664p_16.hex
atmega664p.bootloader.unlock_bits=0x3F
atmega664p.bootloader.lock_bits=0x0F

atmega664p.build.mcu=atmega644p

atmega664p.build.f_cpu=16000000L
atmega664p.build.core=arduino

##############################################################

4) Locate the file “avrdude.conf” which will be located inside the Arduino program folder inside “Resources/Java/Hardware/tools/avr/etc”. Now copy the following text as it is and place it into the avrdude.conf file as the other ICs appear. For the 664p see the changes, you will need two complete entries.

#------------------------------------------------------------
# ATmega1284P                                                               /* change to ATmega664P */
#------------------------------------------------------------

# similar to ATmega164p

part
    id               = "m1284p";                               /* change to m664p */
    desc             = "ATMEGA1284P";                       /* change to ATMEGA664P */
    has_jtag         = yes;
#   stk500_devcode   = 0x82; # no STK500v1 support
#   avr910_devcode   = 0x?;  # try the ATmega16 one:^
    avr910_devcode   = 0x74;
    signature        = 0x1e 0x97 0x05;                    /* change to 0x1e 0x96 0x09 */
    pagel            = 0xd7;
    bs2              = 0xa0;
    chip_erase_delay = 9000;
    pgm_enable       = "1 0 1 0  1 1 0 0    0 1 0 1  0 0 1 1",
                       "x x x x  x x x x    x x x x  x x x x";

    chip_erase       = "1 0 1 0  1 1 0 0    1 0 0 x  x x x x",
                       "x x x x  x x x x    x x x x  x x x x";

    timeout       = 200;
    stabdelay     = 100;
    cmdexedelay       = 25;
    synchloops        = 32;
    bytedelay     = 0;
    pollindex     = 3;
    pollvalue     = 0x53;
    predelay      = 1;
    postdelay     = 1;
    pollmethod        = 0;

    pp_controlstack     =
        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
        0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
        0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
    hventerstabdelay    = 100;
    progmodedelay       = 0;
    latchcycles         = 6;
    togglevtg           = 0;
    poweroffdelay       = 0;
    resetdelayms        = 0;
    resetdelayus        = 0;
    hvleavestabdelay    = 15;
    chiperasepulsewidth = 0;
    chiperasepolltimeout = 10;
    programfusepulsewidth = 0;
    programfusepolltimeout = 5;
    programlockpulsewidth = 0;
    programlockpolltimeout = 5;

    idr                 = 0x31;
    spmcr               = 0x57;
    allowfullpagebitstream = no;

    memory "eeprom"
        paged           = no; /* leave this "no" */
        page_size       = 8;  /* for parallel programming */
        size            = 4096;                                              /* change to 2048 */
        min_write_delay = 9000;
        max_write_delay = 9000;
        readback_p1     = 0xff;
        readback_p2     = 0xff;
    read            = "  1   0   1   0      0   0   0   0",
                          "  0   0   x   x    a11 a10  a9  a8",
                          " a7  a6  a5  a4     a3  a2  a1  a0",
                          "  o   o   o   o      o   o   o   o";

    write           = "  1   1   0   0      0   0   0   0",
                          "  0   0   x   x    a11 a10  a9  a8",
                          " a7  a6  a5  a4     a3  a2  a1  a0", 
                          "  i   i   i   i      i   i   i   i";

    loadpage_lo = "  1   1   0   0      0   0   0   1",
              "  0   0   0   0      0   0   0   0",
              "  0   0   0   0      0  a2  a1  a0",
              "  i   i   i   i      i   i   i   i";

    writepage   = "  1   1   0   0      0   0   1   0",
              "  0   0   x   x    a11 a10  a9  a8",
              " a7  a6  a5  a4     a3   0   0   0",
              "  x   x   x   x      x   x   x   x";

    mode        = 0x41;
    delay       = 10;
    blocksize   = 128;
    readsize    = 256;
      ;

    memory "flash"
        paged           = yes;
        size            = 131072;                         /* change to 65536 */
        page_size       = 256;
        num_pages       = 512;                       /* change to 256 */
        min_write_delay = 4500;
        max_write_delay = 4500;
        readback_p1     = 0xff;
        readback_p2     = 0xff;
        read_lo         = "  0   0   1   0      0   0   0   0",
                          "a15 a14 a13 a12    a11 a10  a9  a8",
                          " a7  a6  a5  a4     a3  a2  a1  a0",
                          "  o   o   o   o      o   o   o   o";

        read_hi         = "  0   0   1   0      1   0   0   0",
                          "a15 a14 a13 a12    a11 a10  a9  a8",
                          " a7  a6  a5  a4     a3  a2  a1  a0",
                          "  o   o   o   o      o   o   o   o";

        loadpage_lo     = "  0   1   0   0      0   0   0   0",
                          "  0   0   x   x      x   x   x   x",
                          "  x  a6  a5  a4     a3  a2  a1  a0",
                          "  i   i   i   i      i   i   i   i";

        loadpage_hi     = "  0   1   0   0      1   0   0   0",
                          "  0   0   x   x      x   x   x   x",
                          "  x  a6  a5  a4     a3  a2  a1  a0",
                          "  i   i   i   i      i   i   i   i";

        writepage       = "  0   1   0   0      1   1   0   0",
                          "a15 a14 a13 a12    a11 a10  a9  a8",
                          " a7   x   x   x      x   x   x   x",
                          "  x   x   x   x      x   x   x   x";

    mode        = 0x21;
    delay       = 6;
    blocksize   = 256;
    readsize    = 256;
      ;

    memory "lock"
        size            = 1;
        read            = "0 1 0 1  1 0 0 0   0 0 0 0  0 0 0 0",
                          "x x x x  x x x x   x x o o  o o o o";

        write           = "1 0 1 0  1 1 0 0   1 1 1 x  x x x x",
                          "x x x x  x x x x   1 1 i i  i i i i";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "lfuse"
        size            = 1;
        read            = "0 1 0 1  0 0 0 0   0 0 0 0  0 0 0 0",
                          "x x x x  x x x x   o o o o  o o o o";

        write           = "1 0 1 0  1 1 0 0   1 0 1 0  0 0 0 0",
                          "x x x x  x x x x   i i i i  i i i i";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "hfuse"
        size            = 1;
        read            = "0 1 0 1  1 0 0 0   0 0 0 0  1 0 0 0",
                          "x x x x  x x x x   o o o o  o o o o";

        write           = "1 0 1 0  1 1 0 0   1 0 1 0  1 0 0 0",
                          "x x x x  x x x x   i i i i  i i i i";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "efuse"
        size            = 1;

        read            = "0 1 0 1  0 0 0 0  0 0 0 0  1 0 0 0",
                          "x x x x  x x x x  o o o o  o o o o";

        write           = "1 0 1 0  1 1 0 0  1 0 1 0  0 1 0 0",
                          "x x x x  x x x x  1 1 1 1  1 i i i";
        min_write_delay = 9000;
        max_write_delay = 9000;
      ;

    memory "signature"
        size            = 3;
        read            = "0  0  1  1   0  0  0  0   x  x  x  x   x  x  x  x",
                          "x  x  x  x   x  x a1 a0   o  o  o  o   o  o  o  o";
      ;

    memory "calibration"
        size            = 1;

        read            = "0 0 1 1  1 0 0 0   0 0 0 x  x x x x",
                          "0 0 0 0  0 0 0 0   o o o o  o o o o";
        ;
  ;

5) We now need to copy the folder called “stk500v2” from the ZIP file and place this into the bootloaders folder as it is. The boot loaders folder is located at “/Resources/Java/hardware/arduino/bootloaders” 6) Restart Arduino. 7) Arduino will now have extra options for a “min 1284p – stk500v2 loader w/20MHz ATmega1284p”

Programming the boot loader

Setup the 1284p on the breadboard as per the instructions earlier but we also need to setup the ICSP header. The ICSP header shares 4 pins with the normal IO plus 5V and GND. 1) Connect the 5V line from the arduino board to the 5V on the breadboard. 2) Connect the GND line form the arduino board to the GND on the breadboard. 3) Look at the 6 pin header from the programmer. 4) Pin 1 is the hole nearest the red wire on the side of the plastic bump/key. This is MISO and goes to pin number 7 of the 1284p 5) Pin 2 is the other hole at the red wire side, this is 5V, connect this to the 5V on the breadboard too. 6) Pin 3 is the middle hole on the key side, this is SCK and goes to pin 8 of the 1284p. 7) Pin 4 is the middle hole on the other side, this is MOSI and goes to pin 6 of the 1284p. 8) Pin 5 is the bottom hole on the key side, this is RST and goes to pin 9 of the 1284p. 9) Pin 6 is the bottom hole on the other side, this is GND and goes to the GND on the breadboard too. You can get break out board to use the ICSP header with breadboard or you can just use 6 breadboard wires.

This is a method that works using AVR studio 5 & AVR ISP mk II.

1) Install AVR Studio v5 2) Extract the HEX file from the ZIP folder 3) Under TOOLS locate “AVR Programming” 4) Select tool “AVRISP mkII”. 5) Select device “ATmega1284p” 6) Select interface “ISP” 7) Click “Apply” 8) Under “Interface settings” move the speed slider all the way to the left. 9) Under “Device ID” click “Read” and you should see the Device ID “0x1E 0x97 0x05” 10) Under “Target voltage” click “Read” and you should see the voltage 4.8V 11) Under “Memories” we can now program the Flash memory, click “…” and select the HEX file. 12) Click “Program” 13) You WILL get a time out warning, click that you want to give it longer (you may have to do this 2-3 times) 14) Click “Verify” and again give it longer. 15) Now we can change the fuses (these are just settings) 16) Click “Fuses” and change the values to EXTENDED = 0xFD, HIGH = 0xD8 & LOW = 0xF7 then click “Program” 17) You can now change the speed of the interface if you like, click on “Interface settings” and slide this to 4MHz. 18) Try programming and verifying again and these should work almost instantly.

This is a method that works using the Arduino IDE & AVR ISP mk II.

1) Under boards locate the correct one for your needs 2) Under tools select "Boot Loader" and "w/ AVR ISP mk II" 3) Disconnect everything and then re-attach breadboard to Arduino board

This is a method that works using the Arduino IDE & USBtiny !!.

1) Under boards locate the correct one for your needs 2) Under tools select "Boot Loader" and "w/ USBtiny" 3) When the Arduino IDE fails with a communication error..... 4) Disconnect everything and then re-attach breadboard to Arduino board

This is NOT an example of my brilliance in the use of all this kit but more an example of the joint effort of several people on the forum and elsewhere.

My thanks to : Andy Kirkby http://aka47.adsl24.co.uk/serendipity/index.php?/pages/Min644pWarez.html, Skyjumper, RetroLefty & Crossroads.

http://www.cowasaki.co.uk/Arduino/1284p.zip

I think you still need 16 MHz xtal for arduino code compatibility.

CrossRoads: I think you still need 16 MHz xtal for arduino code compatibility.

The line:

ADABoot1284P.build.f_cpu=20000000L

leads me to think that maybe it will work with 20MHz. It certainly works with the blink sketch. I will be testing further over the next few days and will update the thread with any corrections that I find. Thanks for you help.

Check with Skyjumper, I think he finally gave up on that after a lot of attempts to make it work.

CrossRoads: Check with Skyjumper, I think he finally gave up on that after a lot of attempts to make it work.

Will do but at the moment I have a 1284p happily flashing away whilst running at 20MHz. I will give it some further testing later.

Read this thread http://arduino.cc/forum/index.php/topic,59701.0.html

CrossRoads: Read this thread http://arduino.cc/forum/index.php/topic,59701.0.html

No problem, I will alter the instructions to give two entries, one for 16Mhz and one for 20Mhz. If someone has a good stable 16Mhz hex for the 1284p I can include that otherwise will need to work out how to create them.

Giving both speeds sounds ideal. Plenty of applications would benefit from the increased speed but not be caused an issue by the listed problems. Plenty of applications simply need the extra io ports which was my initial reason for going down the 1284p route.

I have changed the boards.txt update in the first post to now include the 1284p at both 16MHz and 20MHz plus added the 664p at 16MHz

I have changed the zip file to add the suffix _20 onto the 20MHz HEX file.

I will add the HEX files for the other two asap.

just looked at your breadboard instructions again in particular

4 ) pin 13 to GND via a 22pF capacitor 5 ) pin 14 to GND via a 22pF capacitor 6 ) place 20MHz crystal between pins 13 & 14 ... 9 ) pin 15 to arduino duemilanove board pin RX 10 ) pin 16 to arduino duemilanove board pin TX

I think the crystal goes between 12 and 13 and Tx/Rx are on 14 and 15

or did I misread the pinouts?

mmcp42: just looked at your breadboard instructions again in particular

4 ) pin 13 to GND via a 22pF capacitor 5 ) pin 14 to GND via a 22pF capacitor 6 ) place 20MHz crystal between pins 13 & 14 ... 9 ) pin 15 to arduino duemilanove board pin RX 10 ) pin 16 to arduino duemilanove board pin TX

I think the crystal goes between 12 and 13 and Tx/Rx are on 14 and 15

or did I misread the pinouts?

Thanks,

It is simple really, I can't count :)

Now corrected, thanks Mike!

hee hee - that’s what the pooter is for!

Many thanks to Skywalker (who is clearly the expert here!). He has now supplied me with his HEX files for the 1284p @ 20MHz, 1284p @ 16Mhz & 664p @ 16MHz plus there is a change to the boards.txt which allows it to work with his HEX files. All relevant files are in the zip in post 3.

So all in all this should now work for either chip.

I am currently designing a AT mega 1280/2560 compatible board on Eagle which will be pin compatible where they share the same pins but without the USB/FTDI etc so just the 6 pin ICSP and 4 pin inputs. I will post the top and bottom views of the board if anyone wants them (and will pop one in the post to mmcp42 :))

Grins insanely!

Well for some reason the SkyWalker boards mods & HEX isn't working but the original one still is.

Just discovered that if you copy the HEX file into the folder stk500v2 it will program the boot loader using the Arduino IDE so you do not require AVR Studio. Will try again later with the other programmer too.

EDIT: Actually neither are working at uploading the sketches now!

Aaaaaaaaaaaaaaaaaaaaaarrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhh !!!!!!!!!!!!!

It was all working yesterday, then I stuck the files from SkyJumper in and it stopped working then I put everything back and its not working!

I have installed the IDE on the Windows box and it doesn't work from there either!

I've re-installed the IDE from scratch with all the additions.

I've swapped to a new 1284p IC and swapped the arduino duemilanove boards

I've swapped the crystal and checked all the wiring!!!!!

It programs and verifies via the AVR ISP mkII It reads the IC and does everything it should do.

If I try and upload a program via the AVR ISP mk II then it doesn't run but still verifies! I cannot upload anything via the serial connection.

I've stuck a 328p back in the duemilanove board and that works fine on either mac or windows.

I am now further back than I was yesterday!

Hello,

I just want to add to this post about creating a bootloader for the 1284p.

I took the information from this post and edited the boards.txt file for 16Mhz operation.
I then downloaded the file stk500v2_new.zip from the aka47 website and compiled a hex file for 16Mhz operation
on my PC running Linux Fedora 15.

I then used the Arduino IDE to upload the bootloader using a usbtiny programmer, I had a verification error but it seemed to work.
I also had to update avrdude and ardude.conf in the arduino-0022 path to the latest version.

I then downloaded the core files from the Sanguino site and edited the wiring_pins.c file to add the pins for the 644p/1284p chips.

Here is a list of what I tested so far.
All digital outputs.
All PWM outputs.
Serial1 works also.

I haven’t tested the Analog inputs or the tone functions as of yet.

I did have a lot of problems loading the bootloader at first. I had to put some bypass caps on the breadboard to get this to work.

Thanks to everyone for the information that everyone posted previously to help me get this going.

mnmis

Is there any chance of posting the links to the sanguino files and any modifications. Just so everyone else can benefit.

Thanks.

I think most of what you need Sanguino software-wise is here
http://sanguino.cc/useit