Go Down

Topic: Using the 1284p/664p (IDE, bread board and boot loaders) (Read 25 times) previous topic - next topic

cowasaki

Jun 21, 2011, 08:43 pm Last Edit: Feb 15, 2012, 12:19 am by cowasaki Reason: 1
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.

Code: [Select]

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

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

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





cowasaki

#1
Jun 21, 2011, 08:43 pm Last Edit: Jun 23, 2011, 09:01 pm by cowasaki Reason: 1
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.

Code: [Select]
#------------------------------------------------------------
# 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";
       ;
 ;


cowasaki

#2
Jun 21, 2011, 08:44 pm Last Edit: Jun 23, 2011, 06:26 pm by cowasaki Reason: 1
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

CrossRoads

I think you still need 16 MHz xtal for arduino code compatibility.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

cowasaki


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.

Go Up