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

Showcase your projects! We love to see what people come up with, so please share your creations here.
Post Reply
europa
Posts: 15
Joined: Mon Nov 21, 2011 9:55 am

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

Post by europa » Wed Apr 18, 2012 1:45 pm

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 with the use of the appropriate shield/shields.

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 caunium 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 us 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 then you can email me at matthodge@iinet.au and I will email you the appropriate Eagle files. Also if you have any queries about the clone, email me and I will try to help you out... 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.
Attachments
Figure (i).zip
Figure (i) Circuit schematic
(22.52 KiB) Downloaded 231 times
Figure (ii).zip
Figure (ii) PCB foil design
(34.97 KiB) Downloaded 174 times
Figure (iii).zip
Figure (iii) PCB after etching with H2O2/HCl
(36.59 KiB) Downloaded 180 times
Last edited by europa on Wed Apr 18, 2012 2:16 pm, edited 1 time in total.

europa
Posts: 15
Joined: Mon Nov 21, 2011 9:55 am

Re: ATmega 1284P/"Goldilocks" ... the black sheep of the fam

Post by europa » Wed Apr 18, 2012 1:50 pm

This is to get around the 3 attachment upload limit and add another three attachments.
Attachments
Figure (iv).zip
Figure (iv) PCB component and link layout.
(77.28 KiB) Downloaded 169 times
Figure (v).zip
Figure (v) Clone powered up and talking serial (115200 baud)
(39.49 KiB) Downloaded 165 times
Figure (vi).zip
Figure (vi) Sheathed wire links hiding under DIP chip socket.
(31.68 KiB) Downloaded 158 times

europa
Posts: 15
Joined: Mon Nov 21, 2011 9:55 am

Re: ATmega 1284P/"Goldilocks" ... the black sheep of the fam

Post by europa » Wed Apr 18, 2012 1:53 pm

This is to get around the 3 attachment upload limit and add a final two attachments.
Attachments
Figure (vii).zip
Figure (vii) Kit Ten clone and Calunium clone.
(36.35 KiB) Downloaded 183 times
Figure (viii).zip
Figure (viii) Arduino 1.0 Calunium screen capture.
(40.48 KiB) Downloaded 182 times

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest