Skip to main content

You are here

ATmega1284P "Goldilocks" ... the black sheep of the family!

27 posts / 0 new
Last post
plutonomore
ATmega1284P "Goldilocks" ... the black sheep of the family!

This article describes the construction of an ATmega1284P based Arduino Clone, with quite a few extras thrown in. If the previous sentence has sparked your curiosity, then please read on.

Recently I constructed a Microchip ENC28J60 based Ethernet Controller board clone of the JeeLabs EtherCard. After cobbling this board together it soon became apparent that the ATmega328P, with it's 2K of SRAM could present a few problems. Looking for possible solutions, I read of possible future plans in conjunction with the use of stashes to implement library rewrites, to enable part of the 8K of SRAM on the ENC28J60 to be utilised with different strategies for handling buffer storage problems. Please see JeeLabs blog "Avoiding memory use", 25/5/2012. Also came across an interesting article titled, "The Secret Functions of MikroC Ethernet Library for ENC28J60". This made me think, why not look at this problem from a different perspective, essentially using the KISS philosophy, what about looking at the possibility of using a different cost effective microcontroller with larger SRAM. Look, to be entirely honest, I'm just looking for any excuse to play with another microcontroller. Well, as luck would have it, it soon became apparent that such a beast actually existed. I'm left scratching my head wondering why this microcontroller hasn't been used much more? This mild mannered super chip has the following features ... 128K flash, 4K EEPROM, 16K SRAM!!!, 32 IO pins, 3 interrupts, 2 UARTS, 8 analogue inputs, is available in a 40 pin DIP package, will set you back a king's ransom of $6.90 AUD, from Futurelec and just in case you might be wondering, no, it's not able to leap tall buildings in a single bound.

Now, that this chip's existence has been exposed, the next step is to see what information has escaped into the wild, documenting how to use it. Once again, there are excellent sources of information on slapping together an ATmega1284P project. The two sources that I found most helpful were (i) Steve Marple's blog"Introducing the Calunium - An Arduino Clone based on the Atmega644P/Atmega1284P" and (ii) Maniacbug's blog "Arduino on ATmega1284P". I have to be admit, whenever I come across an author commenting about something in a post as "trivial", it always brings a wry smile to my face, as there is usually at least some degree of struggle in everything, when it comes to this stuff! The plan of attack was now formulated, yes, you probably guessed it, clone Steve Marple's Calunium pcb flavour. The beauty of "Open Source" hardware, is that you can tailor it to your specific requirements and in this vein I decided to design and construct essentially a "bare bones" Calunium / "suped-up" Freetronic's Kit Ten clone. Any extra functionality can be addressed by using any of the plethora of shields that are available,"out there".

Please be warned, this project is constructed as a through-hole, single-sided pcb, uses many insulated and non-insulated links, see Figure (vi) and many of the tracks are in close proximity... how's that for a challenge! Once again the aim of using this format is to hopefully make construction and troubleshooting of the project accessible to the average hobbyist, without the need for any specialist tools/techniques.

The pcb was fabricated using the Toner transfer method, using an etchant mixture of 12% v/v Hydrogen Peroxide and 28% v/v Hydrochloric Acid in a 1:2 ratio. This etchant is an extremely aggressive oxidising agent, so please observe the necessary precautions when handling it. A GBC/Creative A4 laminator was used to produce the Toner Transfer.

Due to the extreme close proximity of some of the wire links on the top-side of the board, it was necessary to leave some wires insulated so that if the wires did make contact there would not be short circuits. This area is pretty much hidden beneath the 40 pin DIP socket. The majority of the wire links are spaced far enough apart to allow the insulation sheath to be stripped off and just the bare wire used. It might be time to seriously consider using the services of someone like Iteadstudio to fabricate pcbs in the future, given the time and expense it takes to cobble a pcb together myself... yes, but I really enjoy crafting these boards by hand.

If you look closely at the board you will surely recognise the Freetronics Kit Ten clone component of the board. The 2N7000 FET is again included to prevent loading of the D13 red LED and the LED is mounted near the end of the extended board, to provide good visibility after stacking. The reset switch has been relocated to allow easy access when other boards are stacked above also. The 5 volt, blue power LED has also been moved to the edge of the board near the 3.3 volt regulator. Also you will notice the standard Arduino footprint as far as the headers go. There are a couple of twists though, with I2C, SDA and SCL pins interchangeable via jumpers to analogue inputs A4 and A5 and instead of the analogue header having the standard six pins, it has eight. There are two extra headers on the board which attempt to mimic the 2560 board layout, to some extent. The ICSP 6 pin header has been repositioned and will no longer enable the Arduino Ethernet/SD shield to be plugged onto it. I use an ENC28J60 based Ethernet card so no great loss as far as I'm concerned. Because the card is longer than the standard Arduino card, two of the mounting holes have been repositioned as well.

The Calunium board will ONLY work with arduino 1.0. To setup arduino 1.0 so that it will talk to the Calunium it is first necessary to download the calunium folder from github and install it in arduino 1.0. If you look for stevemarple/Calunium at github you will find a folder called software, if you look in this folder you will find a folder called calunium. All you have to do is copy this folder to C:\program files\arduino-1.0\hardware. Once copied, if you open the hardware folder you should see three folders, arduino, calunium and tools. If you open the calunium folder you will find a bootloader folder, open this to find a standard folder. On opening the standard folder I found the file atmega1284p_16MHz, which is a bootloader that can talk at a baud rate of 115200. I tried using this bootloader initially but soon found it to be incredibly unreliable when it came to loading sketches... so pretty useless! I remembered reading about an optiboot bootloader on Maniacbug's blog, so went over to his github stuff on the Mighty 1284p, looked under bootloaders/optiboot and found the optiboot_atmega1284p hex file. Then went back to the calunium/bootloaders and created another folder called optiboot, then just copied the optiboot_atmega1284p hex file to it. I have contacted Steve Marple since, about the missing optiboot folder and file, he was good enough to email me the optiboot_atmega1284p hex file, many thanks. Wow, what a difference the optiboot bootloader makes, has been used to upload several sketches now, with a 100% success rate so far.

The ATmega1284P needs to have it's fuses set before installing the bootloader. The low fuse is set to 0xFF, the high fuse is set to 0xDE and the extended fuse is set to 0xFD. I used avrdude and an usbasp v2.0 programmer to set the fuses using the following syntax.

avrdude -v -p m1284p -c usbasp -U hfuse:w:0xDE:m -U lfuse:w:0xFF:m -U efuse:w:0xFD:m

If you are wondering where these fuse settings miraculously appeared from, please follow this path C:\program files\arduino-1.0\hardware\calunium\boards. When you open the boards text file all should be clear! Please note that the default high fuse setting is 0x9E, this was changed to 0xDE so as to lose the JTAG functionality and thus give normal access to digital pins 16 through 19. Initially I tried the clone with the default high fuse setting and ran a simple LED blink sketch and found all digital pins bar 16 through 19 were good, so contacted Steve Marple and he was kind enough to offer the 0xDE solution, thanks again. Once the fuses have been set you can load the bootloader. To do this open the Arduino 1.0 IDE, click tools, set board to Calunium 1284P(PCB,16MHz,optiboot). If you intend to use the usbasp programmer select USBasp. If you intend to try using a usbtiny programmer, well the bad news is, forget it! You can use the usbtiny to set the fuses, no problem but when you try loading the bootloader with it, you will be greeted with "verification error, first mismatch at byte 0x1f000 0x0c != 0xff", you have just crossed the magic 64K boundary limit for this programmer. Please note when using the usbtiny programmer, that it CANNOT be used with microcontrollers with greater than 64K of flash, this obviously becomes an issue with the Calunium, since it has 128K of flash. The usbasp programmer from ProtoStack, up in Queensland, lets me read and write hex programs from and to the Calunium respectively, as well as the likes of the 2560 with it's 256K of flash.It's interesting because if you play around with avrdude and the usbtiny it looks like it writes OK but screws up during the verification stage. Anyway, having selected USBasp, then all you have to do is click on Burn Bootloader. Once the bootloader is successfully installed you can then load whatever sketch you fancy. Probably not a bad idea to load the "Blink" sketch as a first check that all is good. I wrote a couple of other quick sketches, one, as mentioned earlier which highlighted the JTAG issue and another sketch to check out the analogue inputs. Well, guess what, if you follow the Calunium pcb schematic you will find that the Arduino A0 to A7 headers are reversed... the standard A0 header is actually A7 and A7 is actually A0. I contacted Steve Marple about this and he was aware of the problem and said he was working on a fix. I'm now working on a v1.1 clone that wires the A0 through A7 analogue inputs so they follow the standard Arduino footprint.

Looking at Figure (vii), it doesn't take much imagination to see how the "bare bones" Calunium clone has deliberately used the Kit Ten clone, as a template. When looking at Figure (viii), please note the 130048 bytes of flash available for sketches. If you were to use the standard atmega1284p_16MHz bootloader, you would see there are 129024 bytes of flash available. Don't forget this thing also has 4K EEPROM and 16K SRAM!!!

Anyway, this has been a convoluted little roller coaster ride of a project and if you decide you would like to embark on a similar adventure, go for it. I'm attaching the Eagle files for the schematic, Figure(ix).zip and the board, Figure(x).zip. Oh yeah, don't hold your breath as far as the v1.1 clone is concerned, I need to go out and get a life for a while.

AttachmentSize
Figure (i).zip22.52 KB
Figure (ii).zip34.97 KB
Figure (iii).zip36.59 KB
Figure (iv).zip77.28 KB
Figure (v).zip39.49 KB
Figure (vi).zip31.68 KB
Figure (vii).zip36.35 KB
Figure (viii).zip40.48 KB
Figure (ix).zip64.64 KB
Figure (x).zip15.34 KB
JohnO

Well done, great project and writeup plutonomore.

jcw

Terrific project, Matt - the ATmega328 is definitely at the point of diminishing returns with Ethernet, especially in terms of RAM.

This can indeed enable more Ethernet functionality. The next step would be to base the software on uIP, which doesn't have the single-packet TCP limitation.

tankslappa

Wow Pluto, you've been a busy boy! Great work.

Bingo

@Pluto
Thanx for the excellent writeup.

May i suggest , that you have a look at the "Pollin AVR-NETIO".
And maybe make your software mods. Dual-Boarded , if possible.

This would enable users of this fine board , to get a M1284 Ethernode.
Without doing their own PCB , and they can even get an assembled one.

The assembled one might be a good choise for beginners (without a component collection).
The Pollin Kits is like the "IKEA furniture Kits".....
There is always a missing or wrong part.

Price would be around €28..€35 , including the M1284. But excluding the RFM12B module.

Schematic
http://www.pollin.de/shop/downloads/D810058B.PDF
Diy
http://www.pollin.de/shop/dt/MTQ5OTgxOTk-/Bausaetze_Module/Bausaetze/Bau...
Done
http://www.pollin.de/shop/dt/NjI5OTgxOTk-/Bausaetze_Module/Bausaetze/AVR...
MCU Upgrade (Mega1284P)
http://www.pollin.de/shop/dt/OTk4ODk4OTk-/Bauelemente_Bauteile/Aktive_Ba...
AddOn Board
http://www.pollin.de/shop/dt/Nzg4OTgxOTk-/Bausaetze_Module/Bausaetze/Bau...
RFM-12B Adapter (Or use the Jee module below)
http://www.pollin.de/shop/dt/MjY4OTgxOTk-/Bausaetze_Module/Bausaetze/Bau...
RFM12-B (Or use the Jee module below)
http://www.pollin.de/shop/dt/NTg4OTgxOTk-/Bausaetze_Module/Module/Funkmo...

It might be easier to get the RFM12 from JeeLabs (Remember to get the 5v adapter)
http://jeelabs.com/products/rfm12b-board

I suggest one support JeeLabs (RFM12B-Adapter), but i included the above url's for "One Postage/Shipping bill"

/Bingo

plutonomore

Calunium clone v1.1 update,

Hi, I don't like loose ends, so here's the Calunium clone v1.1 details. v1.1 is a hardware solution for the Analogue A0 to A7 standard Arduino footprint being reversed in v1.0. Time to catch a few waves.

AttachmentSize
Figure (a).zip22.2 KB
Figure (b).zip35.84 KB
Figure (c).zip76.97 KB
Figure (d).zip47.87 KB
Figure (e).zip50.54 KB
Figure (f).zip64.64 KB
Figure (g).zip15.43 KB
plutonomore

Full Circle:-

Well since posting, http://forum.jeelabs.net/node/954, things have really moved along. What began with trying to send data using a RFM12B/BP wireless connection and then serving that data up to a webpage, ended up being a bit of a surprise package.

I am happy to report that today I finished successfully testing the completed project. I have an ATmega328p stacked with two 10 bit, 16 channel analogue input clone cards and a RFM12BP wireless card, transmitting 32 channels of 10 bit analogue data to an ATmega1284p Calunium clone stacked with an RFM12B clone card and an Ethercard clone.

It was necessary to edit enc28j60.cpp and RF12.cpp since the Freetronics Kit Ten clone and the Calunium clone have different pin mapping. Both these files can be found in the JeeLib libary for Arduino 1.0. I decided to hang the ethercard off digital pin 8 and the RFM12B off digital pin 10.
To tell your sketch what Ethercard csPin you have chosen to use,
if(ether.begin(sizeof Ethernet::buffer,mymac,8)==0).
So, let's edit the enc28j60.cpp file to look like the following:-

static byte Enc28j60Bank; static int gNextPacketPtr; static byte selectBit; // 0 = B0 = pin 8, 1 = B1 = pin 9, 2 = B2 = pin 10 void ENC28J60::initSPI () { const byte SPI_SS = 10; const byte SPI_MOSI = 11; const byte SPI_MISO = 12; const byte SPI_SCK = 13; pinMode(SPI_SS, OUTPUT); pinMode(SPI_MOSI, OUTPUT); pinMode(SPI_SCK, OUTPUT); pinMode(SPI_MISO, INPUT); digitalWrite(SPI_MOSI, HIGH); digitalWrite(SPI_MOSI, LOW); digitalWrite(SPI_SCK, LOW); SPCR = bit(SPE) | bit(MSTR); // 8 MHz @ 16 bitSet(SPSR, SPI2X); } static void enableChip () { cli(); bitClear(PORTD, selectBit); } static void disableChip () { bitSet(PORTD, selectBit); sei(); byte ENC28J60::initialize (word size, const byte* macaddr, byte csPin) { bufferSize = size; if (bitRead(SPCR, SPE) == 0) initSPI(); selectBit = csPin - 2; bitSet(DDRD, selectBit); disableChip(); // init if (bitRead(SPCR, SPE) == 0) initSPI(); selectBit = csPin - 2; bitSet(DDRD, selectBit); disableChip(); Now let's edit the Rf12.cpp to look as follows: // ATmega168, ATmega328, etc. #define RFM_IRQ 2 #define SS_DDR DDRB #define SS_PORT PORTB #define SS_BIT 4 // for PORTB: 2 = d.10, 1 = d.9, 0 = d.8 // ***for ATmega1284p SS_BIT is PORTB d.10 = 4 (PB4,pin #5 on chip)*** #define SPI_SS 10 // PB2, pin 16 #define SPI_MOSI 11 // PB3, pin 17 #define SPI_MISO 12 // PB4, pin 18 #define SPI_SCK 13 // PB5, pin 19

It turns out that with the Calunium clone combined with the Ethercard clone the amount of free bytes of SRAM is 14,324 compared to the 174 bytes, when using the ATmega328p for the same RF12 etherNode sketch... go figure!

  • Figure(A).zip is a screen capture showing the 14,324 free SRAM bytes !!!
  • Figure(B).zip is the receive stack, consisting of a Calunium clone, a RFM12B wireless clone and an ethercard clone.
  • Figure(C).zip is the transmit stack, consisting of a Kit Ten clone, two input plug clones and a RFM12BP wireless card.

Many thanks to Steve Marple's Calunium blog and Jean-Claude Wippler's JeeLibs library, as I'm quite sure without that input, this project couldn't have been a success.

cheers,
AttachmentSize
figure (A).zip30.45 KB
figure (B).zip32.04 KB
figure (C).zip16.66 KB
plutonomore

Hi Bingo,

Your comment, "Without doing their own PCB" gave me pause to think. Rather than just cater for the Pollin AVR-NETIO, I thought it might be better to produce something more, "Arduino generic". Also, I have been toying with the idea of using a fabrication house to produce a PCB for some time now. Well, your comment inspired me to do just that for the Calunium clone. This would enable any Arduino user to just simply get the pcb, assemble the board and replace the 328P Arduino board with the 1284P Arduino board. I have sent the pcb Gerber files over to IteadStudio, somewhere in China and when they return the completed boards and they are successfully tested I will post the details here. So, for anyone who wants a really easy upgrade path to an ATmega1284P based Arduino ... well Christmas has come early!

JohnO

Nice one.

plutonomore

RIP ATmega328P,

As stated earlier, am attaching details of ATmega1284P pcb sent off to IteadStudio. This board is a clone of the Calunium project but just to differentiate it from the Calunium I have called it, Elouera v1.1. Unlike Arduino and Calunium, Elouera sure ain't Italian!

Please find attached the Eagle files for the board and the Gerber files sent to IteadStudio. http://iteadstudio.com/store/index.php?cPath=19_20. Also downloaded the IteadStudio design rule(dru)(ITead_rule)check from the site.

Downloaded the Gerber cam (sfe-gerb274x.cam)file from here: http://www.sparkfun.com/tutorials/109

Used viewplot to check the Gerber files.http://www.viewplot.com/pcbe_index.html

As mentioned previously this should enable any hobbyist an easy 328P to 1284P upgrade path.

cheers,
JohnO

Excellent, will we be able to buy the PCB's?

plutonomore

Hi JohnO,

Yes, you will be able to buy the pcbs but I do not wish to get involved in the supply process, as I just wanted to provide a mechanism to facilitate an easy upgrade path. If you want pcbs, all you have to do is place an order with IteadStudio, send them the Gerber files and wait for them to be posted out to you. You will also have to exercise a bit of patience as far as shipping/delivery time is concerned, as it can be quite slow at times. At the moment I noticed IteadStudio are offering a special May deal of 10(TEN) GREEN boards for $24.90.See the following link: http://iteadstudio.com/store/index.php?main_page=product_info&cPath=19_2...

You should be up for something like $5.00, for postage as well. So for around $30 bucks this would seem a pretty good deal. It would be even better if a purchase for a group could be made, as this would obviously cut costs significantly.

If you do purchase some pcbs and if you can spare the time, I would appreciate your feedback.

cheers,
plutonomore

PCB photos:

You might find these photos of the ATmega1284P pcb of interest. Apologise for not including them in the earlier posts. Must admit, am very impressed with the quality and economy of the boards from IteadStudio. Please understand, I have no affiliation with IteadStudio but just like to give acknowledge good work.

cheers,
AttachmentSize
IMG_3112.JPG143.51 KB
IMG_3114.JPG132.46 KB
JohnO

The boards look excellent, have you built one up yet? I guess I'm asking if the PCB is 100%

plutonomore

Hi JohnO:

If you have a look at the attached photos, you can see an assembled and tested board. As a check of the board have run a sketch to drive a LED attached to D2-D23 successfully. Also ran a sketch to display analogue inputs A0 to A7 successfully. A third sketch which receives 32 channels of 10 bit analogue RFM12BP wireless analogue data and serves it up to a webpage, using a JeeLab's Ethercard clone also worked successfully. These three sketches worked for me, obviously can't make any guarantees as far as other sketches are concerned.

Please take careful notice (images 3123 and 3125)of the physical orientation of Q1, the 2N7000 FET. When looking at the silkscreen Q1 orientation and the actual orientation of Q1, it's evident that Q1 is rotated approximately 120 degrees anticlockwise relative to the silkscreen mask. If Q1's orientation isn't correct, well, you will not have a working D13 LED. Moral of the story, never turn your back on an autorouter.

iTeadStudio sent two extra boards, at no extra cost, who knows why? I don't suppose you might be interested in having a play with one of them?

cheers,
AttachmentSize
IMG_3123.JPG184.64 KB
IMG_3125.JPG126.73 KB
IMG_3127.JPG114.32 KB
JohnO

Wow, what a kind offer plutonomore. I'd love to have a play with a spare board. I will pm you.

Your account isn't enabled for contacts. Could you perhaps pm me?

JohnO.

plutonomore

JohnO;

Drop me an email, matthodge at iinet.net dot au, if you like.

cheers,
JohnO

Tankslappa, could you edit the email address in this post to hide it from the baddies?

tankslappa

Like that? :-)

JohnO

Spot on - many thanks TS

JohnO

Hi Plutonomore,

Your PCB arrived safely this morning. The collection of components has been sluggish up to now, I need to pick up the pace. Its a very nice board and I look forward to putting all together. I will let you know how I get on.

Once again many thanks!

JohnO

Hi Plutonomore,

Do you have a part number for SW1?

plutonomore

JohnO part details:

Link to TACT013 futurelec part as used on board: http://www.futurlec.com/Switches/TACT013.shtml

Link to what looks like a Radiospares equivalent,SKHLAD, although grey in colour. http://australia.rs-online.com/web/p/tactile-switches/3367075/?searchTer...

cheers,
point5

Hi plutonomore, thanks for this info, much appreciated.... i'm going to give this a whirl :-) Keen to try running off 3V3 though with an 8Mhz crystal, do you by any chance know what I will need to change re: fuses, bootlaoders etc? Cheers.

plutonomore

Hi point5,

Sorry for the delay in getting back to you but have been busy working on another little project. Hope to post the details here some short time in the future.

The Elouera board I built up uses a 5 volt supply and an external 16MHz crystal, while you are suggesting that you are going to try a 3.3 volt supply and 8 MHz crystal. If you look at page 30, Table 7.3 of the Atmel Atmega1284P manual, you will see that for the the Frequency range 8.0 - 16.0(Mhz) the CKSEL 3..1 fuse setting is 111. I haven't tried your suggested configuration but I would suspect that as far as fuse settings are concerned you should get away with the same fuse setting as the original Elouera. ie low:FF, high:9E with JTAG enabled / DE without JTAG enabled and efuse:FD.

If you do cobble this project together I would be eager to hear of your adventures!

cheers,
point5

Thanks Plutonomore, much appreciated. Hoping to get this project together after the hols - will let you know how it goes. Cheers

MichelV

Interesting project (though for most of my uses, it's not yet justified to pay for the more expensive chip yet ;-)).

Premium Drupal Themes by Adaptivethemes