Arduino Forum

Using Arduino => Microcontrollers => Topic started by: malc-c on Jan 13, 2013, 07:21 pm

Title: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 13, 2013, 07:21 pm
Hi guys,

I've purchased a chip off e-bay which was programmed with the bootloader so I could learn about these devices, but without purchasing the normal arduino board as funds were tight.  I have the device running on a breadboard flashing the led using the default example code.  However one of the projects I want to build requires a 40 pin chip as there isn't enough pins on the standard chip.  If I purchased a blank atmega1284p can I upload a bootloader to it using the current chip running the Uno platform ?
Title: Re: atmega1284 programming from a 328 chip
Post by: retrolefty on Jan 13, 2013, 08:03 pm
Actually you have two different issues to deal with, 1. installing a bootloader onto a blank 1284P chip and 2. modifiying the arduino IDE to be able to function with a 1284P based chip.

The first is rather simple if you use Nick's great sketch that runs on any arduino board and will interrogate the target chip and if it sees that it is a 1284P will install a booloader onto the chip. Although I'm not sure what 'flavor' bootloader it installs.

http://www.gammon.com.au/forum/?id=11635

The second task is to download and install the needed files and folders to modify the arduino IDE to allow it to work with the 1284P chip. Member maniacbug has done all the hard work and has all the file/folders needed to allow that to happen. However the detailed step by step instructions to follow are beyond my ability right now, I just kept fuszing around with it rather randomly and with most difficulty finally was able to get the IDE to work with a 644P chip, as I'm still waiting for a 1284P chip to show up in the mail. So it's certainly doable but all the steps needed can be error prone if it's your first time and no one is around to hold your hand.  ;)

https://github.com/maniacbug/mighty-1284p
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 13, 2013, 10:01 pm
Thanks for the input.

Is there already a 40 pin DIP Arduino that can be purchased with a bootloader installed ?

The idea is to breadboard the project and then design a PCB, rather than go down the route of using shields.  I did something similar with a PIC some years back

(http://www.micro-heli.co.uk/MK2back.jpg)

However, I had a lot of assistance with PicBASIC Pro and having now discovered Arduino's love how easy it is to develop the code and move the project along quickly...
Title: Re: atmega1284 programming from a 328 chip
Post by: fungus on Jan 13, 2013, 10:26 pm
If you want to build standalone devices a $10 ISP programmer is much better than messing about with bootloaders.

You can also use them to set the chip fuses, etc. (which is something you'll want to do...)

http://www.ebay.com/sch/i.html?_nkw=arduino+isp+programmer
Title: Re: atmega1284 programming from a 328 chip
Post by: fungus on Jan 13, 2013, 10:29 pm

Is there already a 40 pin DIP Arduino that can be purchased with a bootloader installed ?


Ar you sure you need one? It's easy to add extra I/O to Arduinos using external shift registers, eg. the 74hc595 (http://arduino.cc/en/Tutorial/ShiftOut)...
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 13, 2013, 10:36 pm
Thanks for the links...

To be honest, I need to do some further research, I wasn't under the impression that the AVR could be programmed like a PIC chip.  If that is the case then one of those ISP might be the option.  I'll also look at shift registers, but ideally having direct ports would be easier for my brain cells round :)

Title: Re: atmega1284 programming from a 328 chip
Post by: fungus on Jan 13, 2013, 11:04 pm

To be honest, I need to do some further research, I wasn't under the impression that the AVR could be programmed like a PIC chip.  If that is the case then one of those ISP might be the option.


Google for "standalone arduino"...
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 13, 2013, 11:56 pm



Google for "standalone arduino"...



Have done, but most throw up breadboarded 328 chips, which is what I currently have
Title: Re: atmega1284 programming from a 328 chip
Post by: CrossRoads on Jan 14, 2013, 02:22 am
Sounds like you need a duemilanove style 1284 board:
Schematic, suggested PL here
http://www.crossroadsfencing.com/BobuinoRev17/
Bare boards $5 mailed to you, paypal to me, cardinalflyer at comcast dot net
(http://www.crossroadsfencing.com/BobuinoRev17/1284_thruhole2.JPG)
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 14, 2013, 09:26 am
Looks like it :)

I'll drop you an e-mail shortly
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 17, 2013, 10:23 am
Crossroads... sent you a mail but not received a reply.. looking for the cost of a bare board and a bootloader programmed 1284 posted to the UK.  Can you advise please
Title: Re: atmega1284 programming from a 328 chip
Post by: CrossRoads on Jan 17, 2013, 07:51 pm
When did you send it?  I don't think it arrived, I've been watching for one. Or I missed in the daily flood of forum e-mails.

Anyway, $5 for the board, $8.14 for the 1284Pchip, no charge for bootloading, $5 for shipping in padded envelope.
So $18.50, paypal to cardinalflyer at comcast dot net

You will be building up for 16 MHz operation with a crystal, yes?
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 17, 2013, 08:49 pm
Hi,

Yes, using a 16mhz xtal with caps.

Have sent you a PM regarding the previous mail etc

Malcolm
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 24, 2013, 11:53 pm
Robert,

Fantastic service - and whilst I wait for a few of the other components to arrive I've breadborded the 1284p as per this schematic

(http://www.flickr.com/photos/maniacbug/6413368937/)

having downloaded the files from the site http://maniacbug.wordpress.com/2011/11/27/arduino-on-atmega1284p-4/ (http://maniacbug.wordpress.com/2011/11/27/arduino-on-atmega1284p-4/)  I can select the board in the drop down list, however when I come to upload the blink example I get the attached error.

I've tried swapping the TX / DX leads - no affect, different baud rates - no affect - on my FTDI board I get what seems to be a good comms as both TX and RX leds pulse, and shorting these wires results in an echo on the serial monitor, so the FTDI is working fine.

Anyone have any suggestions.  I thought the transition from PIC to AVR / Ardunio was going to be a smooth one !

Title: Re: atmega1284 programming from a 328 chip
Post by: CrossRoads on Jan 25, 2013, 02:38 am
Can't see the schematic, try again?

Do have DTR connected as well?  If not, you'll need to press Reset after the "Binary sketch size" message comes up.
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 25, 2013, 09:04 am
Lets see if this works

(http://farm8.staticflickr.com/7009/6413368937_48cacb7410.jpg)

ignore the ISP connections, I've just used the serial connection shown

and yes I've tried DTR connected via the 0.1uf capacitor, and without - It doesn't get that far to reset the chip
Title: Re: atmega1284 programming from a 328 chip
Post by: Frisky on Jan 25, 2013, 11:30 pm
Hi Crossroads
  Could I use my JTAGICE that has a ISP 6pin connector to program a bootloader into a ATMega1284p?
Would I use the Aduino IDE or AVR Studio 4.18?
  How does this chip fair as an Arduino say with the SPI system for the W5100 ethernet controller.
I ordered a few of these from Mouser. I also have a STK500 also I could use with a 16Mhz crystal too.
Don
Title: Re: atmega1284 programming from a 328 chip
Post by: CrossRoads on Jan 26, 2013, 12:30 am
I don't know what is involved with using JTAGICE to program via ISP. This came up in another thread recenly, outlook was not good.
I use Atmel AVR ISP MKii myself, thru the IDE.  Have to find the IDE driver here for it:

Its an 8-bit AVR, so would fair as well as the others for W5100 ethernet controller.
Title: Re: atmega1284 programming from a 328 chip
Post by: cyclegadget on Jan 26, 2013, 01:04 am

@malc-c

What FTDI are you using? Also, it is possible you have the RX and TX swapped. It will not hurt anything to try swapping those leads.
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 26, 2013, 12:11 pm


@malc-c

What FTDI are you using? Also, it is possible you have the RX and TX swapped. It will not hurt anything to try swapping those leads.


It's a sparkfun FT232 Brakeout board.  It worked fine with the original 328P, and I've also tried swapping the TX and RX lines over.  I get pulses on the TX / LX leds, its as if the software is sending a request to upload the data, but not receiving the Ok to send it.  I'll strip the breadboard and re-wire it just in case I've missed something (I seem to remember I had a similar issue with the 328P until I tied one of the voltage reference pins to supply.)
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 27, 2013, 10:01 pm
Well after spending most of my time sorting out the arrangements following a bereavement in the family I have been able to spend a few hours trying to get the 1284P to talk with the PC and upload a program.  But to no avail.

Just to prove that the FTI breakout board was working fine, I breadboarded the 328P chip I received off e-bay, and could upload the blink and fade exampled with no issue.  Breadboarded the 1284P and hooked up the FTI board - no matter what board I select from the dropdown option I get the attached error.

Looks like I'll have to have a re-think on my project to see if I can do all the control I want using the 328P :(
Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 27, 2013, 10:30 pm

ignore the ISP connections, I've just used the serial connection shown

and yes I've tried DTR connected via the 0.1uf capacitor, and without - It doesn't get that far to reset the chip


If this is board, it appears to provides 3.3V be default, not 5V,
https://www.sparkfun.com/products/718

You definitely need to have the DTR wired via 0.1uF cap to do the proper reset. You also need to
have the Rx,Tx pins swapped as shown in your schematic, if using a regular FTDI cable or FTDI Friend.
For the sparkfun board, you just have to be certain the signals flow in the correct directions.

I always use 1K resistors in Rx,Tx lines in case of mistaken cross-wiring.
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 27, 2013, 10:49 pm
Thanks for the reply.  The Sparkfun board has a means of running at 5v (basically de-solder a link and bridge the two pins ( https://forum.sparkfun.com/viewtopic.php?f=15&t=21234 )

Like I said, it works fine when using the normal 328P with the uno bootloader.  It looks to me as if the optiboot isn't talking the same language or at the same speed ! - hence the protocol error
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 27, 2013, 10:58 pm
Bit more googling and it seems to be due to resetting too soon.  I found this regarding the error - OK it's related to programing the 328... but my guess it the same thing happening with the 1284P

Quote

Having investigated this a bit, it seems that the problem is because the Optiboot loader resets the ATMega328 when the serial port is opened. When avrdude is started up to program the slave chip it firsts opens the serial port then tries immediately to write to it. The initial comms fail because the chip has reset and, whilst in the bootloader, isn't actually responding to the STK500 protocol.


Just need to find a way of resolving it
Title: Re: atmega1284 programming from a 328 chip
Post by: cyclegadget on Jan 27, 2013, 11:44 pm

malc-c,

Can you connect a LED and resistor to chip pin 19? It want is used for Arduino pin 13. It will blink a couple of times when the chip is powered to show that the bootloader is working. Also, you will see the LED go out when reset is pressed.
Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 28, 2013, 03:45 am
Quote
Having investigated this a bit, it seems that the problem is because the Optiboot loader resets the ATMega328 when the serial port is opened. When avrdude is started up to program the slave chip it firsts opens the serial port then tries immediately to write to it. The initial comms fail because the chip has reset and, whilst in the bootloader, isn't actually responding to the STK500 protocol.

This doesn't make much sense, because practically every 328 chip anymore uses optiboot, and they don't
fail. Unless there is some issue between uploading using the Arduino IDE via the comport, versus using a
separate programmer.

Also, as mentioned in the other recent 1284 threads, I and others have been using optiboot on the 1284
and uploading using the Arduino IDE, and it works [although a lot of people are having a 1284P problem,
still unresolved]. In my case, it always works for 328, 1284, 1284P, optiboot, 84 KByte uploads, and
the Arduino IDE in all versions.

Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 28, 2013, 10:13 am
Thanks for the replies.

I too have no idea what is happening.  When the 328P is breadboarded, with DTR connected to  the reset via a 0.1uF capacitor in series and a 10K pull up resistor I can select the Uno as the board in the IDE and it uploads many of the example sketches.  With the 1284P chip breadboarded in the same way it fails with the errors shown.

I made the following observation:
When a successful upload on the 328P is achieved, the TX and RX leds on the FTI board initially flash a few times, pause and then flash for a longer period.  It's as if the software is initially checking for the chip, the chip identifies itself and agrees to accept the code, which is then transmitted.  When breadboarding the 1284P I get the initial flashes on the TX / RX leds on the FTI, but then the IDE pauses before the time out results in the errors. 

I'm no expert, but it seems to me as if the bootloader is communicating correctly.  I've tried different baud rates, but with the normal standard port settings.. I assume the optiboot loader uses the standard serial protocols ?

Title: Re: atmega1284 programming from a 328 chip
Post by: leo72 on Jan 28, 2013, 06:23 pm
During the last days I did a lot of tests trying to solve the problem mentioned here (http://arduino.cc/forum/index.php/topic,139671.0.html).
If you're using the Mighty-1284p files (https://github.com/maniacbug/mighty-1284p) by maniacbug, select the board "Mighty 1284p 16 MHz w/Optiboot" then put a 220K resistor in series on the line beetween the FT232 TX and the 1284p RX0 pins.

If you're using the "Original Mighty 1284p" board, then you could try with a 120K R. Or, maybe, without components.

Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 28, 2013, 11:29 pm
Leo, thanks for the reply... I don't have any 220K, but tried with 100K and still no joy.  I've looked through that thread and noted some comments of the baud rate, so checked the boards.txt file and noted that it stated 115200, so I tried this and again got the same sync error.   I know the FTI board is working fine as I can program the 328P with no issue (no serial resistors required, and even with the port set to this fast speed).

I'm finding all this very frustrating. Programming PICs using PicBASIC now seem a lot easier compared to using larger processors other than the original arduino based 328P.  I used to wonder why so many projects on the web had "shields" stacked one on top of another and then the lot placed into a box rather than the traditional breadboard and then dedicated PCB (be that stripboard or printed) approach.  Having spend all this time fuffing about with the 1284P I can now see why !

One last question... having got the 328P running on the breadboard, is it possible to use that to program the 1284p via ISC using MOSI / MISO / SCK pins or do I need a dedicated programmer for that ?

Cheers

Malcolm
Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 28, 2013, 11:56 pm
After reading back through this thread, it appears you never burned the bootloader into the 1284P
chip yourself, but have been assuming the chip you bought has a proper bootloader burned into it.
However, given the nature of ebay, that may be a bad assumption - given comments by others
who've bought things on ebay.

So, maybe you should just try starting over and burning the bootloader yourself, using a regular
Arduino in ArduinoISP mode.

Alternatively, scrub this mission, and just buy a 1284 board from Crossroads.

Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 29, 2013, 12:11 am

After reading back through this thread, it appears you never burned the bootloader into the 1284P
chip yourself, but have been assuming the chip you bought has a proper bootloader burned into it.
However, given the nature of ebay, that may be a bad assumption - given comments by others
who've bought things on ebay.

So, maybe you should just try starting over and burning the bootloader yourself, using a regular
Arduino in ArduinoISP mode.

Alternatively, scrub this mission, and just buy a 1284 board from Crossroads.




Thanks for the comments - but the 1284p was purchased from Crossroads, with a request to have the bootloader installed.  I have also purchased one of his unpopulated PCB's but not had a chance to build it due to a few component shortages in my hobby box.  This was why I've breadboarded the 1284P.

The 328P purchased from e-bay works fine ;-)
Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 29, 2013, 12:33 am
Well, given all the problems here, you might just build up the minimal cktry on the Crossroads
board and try that. All you need for a minimal working ckt are the parts shown in reply #15,
unless the board use a USB chip.
Title: Re: atmega1284 programming from a 328 chip
Post by: CrossRoads on Jan 29, 2013, 06:34 am
He did, and a 1284P chip.
malc-c, are you having all this trouble with that chip?

You should have these settings in your boards.txt
Code: [Select]

bobuino.name=Bobuino
bobuino.upload.protocol=arduino
bobuino.upload.maximum_size=130048
bobuino.upload.speed=115200
bobuino.bootloader.low_fuses=0xff
bobuino.bootloader.high_fuses=0xde
bobuino.bootloader.extended_fuses=0xfd
bobuino.bootloader.path=optiboot
bobuino.bootloader.file=optiboot_atmega1284p.hex
bobuino.bootloader.unlock_bits=0x3F
bobuino.bootloader.lock_bits=0x0F
bobuino.build.mcu=atmega1284p
bobuino.build.f_cpu=16000000L
#bobuino.build.core=arduino:arduino
bobuino.build.core=standard
bobuino.build.variant=bobuino

and be selecting Bobuino as the board type.

This is the bootloader I installed.
This is the pins_arduino.h that goes with the board.

There was discussion in another thread that this line needs to change to make the analog pins line up correctly
Code: [Select]

// #define analogPinToChannel(p)     ( (p) < NUM_ANALOG_INPUTS ? NUM_ANALOG_INPUTS - (p) : -1 )
#define analogPinToChannel(p)       ( (p) < NUM_ANALOG_INPUTS ? (NUM_ANALOG_INPUTS-1) - (p) : -1 ) // test to see if A0-A7 are off by 1
Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 29, 2013, 08:36 am
I'm surprised now that he had so much trouble. The Bobuino bootloader works fine, I've
burned it into several chips now. The process is straightforward, unless Bobuino forgot
to burn it [!!]. OP's setup was minimal, so hard to mess up. There's always something going
on they don't tell us, :-).
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 29, 2013, 11:17 am
Hi Robert, yes it is the supplied chip

I extracted the Arduino IDE to a folder on my desktop.  In the path C:\Users\admin\Desktop\arduino-1.0.3-windows\arduino-1.0.3\hardware\maniacbug-mighty-1284p-68ed99c I have a boards.txt file and within it there is the following section

Code: [Select]



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

bobuino.name=Bobuino
bobuino.upload.protocol=arduino
bobuino.upload.maximum_size=130048
bobuino.upload.speed=115200
bobuino.bootloader.low_fuses=0xff
bobuino.bootloader.high_fuses=0xde
bobuino.bootloader.extended_fuses=0xfd
bobuino.bootloader.path=optiboot
bobuino.bootloader.file=optiboot_atmega1284p.hex
bobuino.bootloader.unlock_bits=0x3F
bobuino.bootloader.lock_bits=0x0F
bobuino.build.mcu=atmega1284p
bobuino.build.f_cpu=16000000L
#bobuino.build.core=arduino:arduino
bobuino.build.core=standard
bobuino.build.variant=bobuino

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



I have tried selecting the bobuino from the dropdown list of boards in the IDE and still get the same error.

The chip is breadborded on a solderless breadbord, with just supply pins connected, 16mhz xtal and RX / TX lines from the working FDI board and a 10K resistor between RESET and +ve - The power is supplied from the +5v USB feed from the FDI board (in the same way the 328P is powered).  I have the DTR line connected to the RESET pin via a series 0.1uf capacitor.  I've also tried taking the VREF pin to +5v too.

I've tried using the trick with a series resistor inline with the TX/RX lines.  Baud set to 115200, 8bit, no parity, and 1 stop bit (although all other baud rates have been tried)
Title: Re: atmega1284 programming from a 328 chip
Post by: leo72 on Jan 29, 2013, 02:09 pm
@malc-c:
100K is too less. Try with 2 100K in serie (=200K).
Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 29, 2013, 08:22 pm
Quote
I have tried selecting the bobuino from the dropdown list of boards in the IDE and still get the same error.

The chip is breadborded on a solderless breadbord, with just supply pins connected, 16mhz xtal and RX / TX lines from the working FDI board and a 10K resistor between RESET and +ve - The power is supplied from the +5v USB feed from the FDI board (in the same way the 328P is powered).  I have the DTR line connected to the RESET pin via a series 0.1uf capacitor.  I've also tried taking the VREF pin to +5v too.

I've tried using the trick with a series resistor inline with the TX/RX lines.  Baud set to 115200, 8bit, no parity, and 1 stop bit (although all other baud rates have been tried)

Exactly the same optibootloader is burned into all the chips from the maniacbug directory,
so selecting any of the 1284 boards from the drop down menu will work for uploading
sketches - only the pin assignments will be different. Eg, D13 [led] is chip pin 8 for Bobuino,
but chip pin 19 for other board selections.  

I assume you included the 22pF caps in addition to the xtal? Have to have those too, unless
you're using a ceramic resonator.

Have you actually measured 5V on the Vcc and Reset pins?

Also, you might try the low-pass filter in the RX0 line, people are using 10K series-R and
100pF to gnd at the RX0 pin. It's possible the chip Crossroads sent is from a batch with the
RX0 noise sensitivity.

I would also try building up the Crossroads board in minimal fashion to test.

I'm having no problems with my own 1284 test boards, so it should work for you too.



Title: Re: atmega1284 programming from a 328 chip
Post by: retrolefty on Jan 29, 2013, 08:30 pm
Woot, my 1284P chip from China just arrived in the mail today, so later today I will see if I have any problems upgrading my Bobuino board from a 644P to a 1284P. No time to get started in it till a little later.

Lefty

Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 29, 2013, 08:31 pm
Quote
I extracted the Arduino IDE to a folder on my desktop.  In the path C:\Users\admin\Desktop\arduino-1.0.3-windows\arduino-1.0.3\hardware\maniacbug-mighty-1284p-68ed99c I have a boards.txt file and within it there is the following section

BTW, I don't know if this matters, but I believe maniacbug said to locate the 1284 bootloader
files in the Arduino "sketch" directory, not the Arduino IDE directory, which is what the above
seems to indicate [maybe].
Title: Re: atmega1284 programming from a 328 chip
Post by: Docedison on Jan 29, 2013, 08:48 pm
Quote
Quote
I have tried selecting the bobuino from the dropdown list of boards in the IDE and still get the same error.

The chip is breadborded on a solderless breadbord, with just supply pins connected, 16mhz xtal and RX / TX lines from the working FDI board and a 10K resistor between RESET and +ve - The power is supplied from the +5v USB feed from the FDI board (in the same way the 328P is powered).  I have the DTR line connected to the RESET pin via a series 0.1uf capacitor.  I've also tried taking the VREF pin to +5v too.

I've tried using the trick with a series resistor inline with the TX/RX lines.  Baud set to 115200, 8bit, no parity, and 1 stop bit (although all other baud rates have been tried)

There has been a great deal of discussion of the connections and the code.. But, No mention of any bypassing.. The 100 nF caps on Vcc and AVcc are NOT optional.

Bob
(Edit for clarity. RKJ}
Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 29, 2013, 08:49 pm
Always count on d_e to remember bypassing, :-). I never liked using those silly whiteboards
for prototyping.
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 29, 2013, 09:20 pm
Guys, thanks again for the support.

I have one question as I'm getting a little confused.  Can someone draft up a simple schematic on how I should hook this up, with the mention of 100pf caps in AVcc etc, low pass filters on the TX and or RX lines... etc. 

I'll also try moving the files to different folders as suggested.

I'll also order up the components to assemble Roberts PCB to see if the issue is with the breadboard... but that might be a while as funds are limited at the moment.
Title: Re: atmega1284 programming from a 328 chip
Post by: Docedison on Jan 29, 2013, 09:25 pm
For what they are... basically modeling a small circuit at low speeds and low power < 1W they are useful however until one really learns the limitations, High interconnection (pin to pin) capacity. Noisy, Dirty and intermittent connections (I recommend a marine lubricant called LPS) and relatively high supply rail resistance > 1 ohm...
Keeping that in mind, When a circuit works put it in place on a proto shield, re test it carefully to verify that the breadboard values are the real values and go on to the next part. Breadboards aren't meant for permanent and complete projects, they are a medium for Modeling a limited subset of electronics with the understanding that the results may be dependent on values used to compensate for the effects of the breadboard. This includes but is not limited to High Speed anything. Breadboards become real 'unusual' at speeds above 50 MHz. Low Noise anything. dealing with millivolt levels on a breadboard is problematical from several standpoints. High Voltage anything. Any voltage greater than 25 V should be avoided or put on a separate breadboard with HV isolation and finally RF anything including antenna connections, Especially antenna connections.
Finally, LCD backlight currents are really too big for connection to a power rail except at the same place the power does. This helps to avoid the voltage drops caused by the backlight current.
I need to repeat that again because of the structure and properties of a breadboard, twice as many bypasses as would be required on a finished PCB type of construction and this includes soldered proto boards too might not be enough. It's easy and virtually free to put down the footprints in the final PCB design, A little testing will tell you which ones are needed and which are optional.

Bob
{Edit: Funny thing wuz that it all made sense... when I wrote it. RKJ
Title: Re: atmega1284 programming from a 328 chip
Post by: Docedison on Jan 29, 2013, 10:32 pm
The 2 minimum bypasses are 100nF, .1 uF capacitors one from Vcc to ground and one from AVcc to ground close to the chip which at least on the 28 pin devices are across from each other so a 100nF/.1uF cap across pins 7 and 8 (Vcc) and 20 and 22 (AVcc). Adding a 10 to 22 uF cap couldn't hurt... Unless you put it in backwards... Messy and stinky, that.

Bob
Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 29, 2013, 11:25 pm
Quote
I'll also order up the components to assemble Roberts PCB to see if the issue is with the breadboard... but that might be a while as funds are limited at the moment.

I should think you'd have enough components from your protoboard ckt of reply #15 to wire
the Crossroads pcb for minimal testing. At least you know the wiring is straight.

And yeah, the 100pF I mentioned was for the RX0 low-pass filter, 100nF is for bypassing Vcc.
Title: Re: atmega1284 programming from a 328 chip
Post by: retrolefty on Jan 29, 2013, 11:41 pm
Well I would like to report a successful 1284P installation, so I will.  ;)

I'm using CrossRoads great through-hole Bobuino board and so far no signs of serial uploading problem using a 68K big sketch on repeated tries, no errors reported or seen.

So I would like to thank CrossRoads for designing, building, and selling a great blank PCB that will support 644P and 1284P chips, and a big hand to Nick's great bootloader program that kept me from having to purchase a more capable hardware programmer then the USBtiny that I do have.

So my Arduino (well one of them anyway) now has 16K of SRAM, how large is yours?  :D

Lefty
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 29, 2013, 11:45 pm
Well if it's good enough for Lefty.... I'll build the PCB tomorrow and report back.
Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 30, 2013, 03:41 am
So lefty, what is the data code on your chips? The 1284Ps I got last week are 1247.

Title: Re: atmega1284 programming from a 328 chip
Post by: retrolefty on Jan 30, 2013, 04:13 am

So lefty, what is the data code on your chips? The 1284Ps I got last week are 1247.




Forgot all about datacode thing. Just checked and it's a 1247 also, so either 47th week or 47th batch of 2012, sounds like a fresh one to me.

Which remind me that starting Friday for 3 days our Local Lucky grocery store is having a sale of fresh (not previously frozen) Dungeness crab for $3.99 a pound. Quite a reduction if price as it's been pretty high this year.

Lefty
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 30, 2013, 02:40 pm
OK we have a result.... it programs with no errors

I followed the notes on this site (http://www.gammon.com.au/forum/?id=11637 (http://www.gammon.com.au/forum/?id=11637) I breadboarded both chips and having confirmed the 328P was working, hooked up the ICP pins between both chips.  Loaded his sketch that interrogated the 1284p and the serial monitor reported details as described, so that proved the 1284p was running.  I then sent the command to upload the optiboot loader which again came back as successful.   I continued down the page and downloaded the files from Maniacbug's site again and copied them to the hardware folder, confirming the operation to overwrite the existing files.

Removed the ICP wires and connected the RX and TX lines, with the DTR to reset via the 0.1uf capacitor.  I also found and placed a 220K resistor in series with the TX line from the FTDI board (had previously tried this with the same sync errors before I re-loaded the bootloader).  Loaded the BLINK sketch, selected the Mighty 1284p optiboot 16mhz board and clicked on the upload....and waited

The TX and RX leds flickered as they did before... then flickered again as data was transmitted.... I hocked up the LED to pin 19 (D13 in the mappings) and it's flashing away as I type. :) :)

My only conclusion, and I don't mean this with any disrespect, is that the initial upload of the bootloader either failed, or in some way got corrupted ??

Anyway... I'm a happy bunny now, and can now start work on building my aquarium controller project - Thanks to all those who have commented and offered suggestions

Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 30, 2013, 06:54 pm
Well, good at last. Breadboarding on both sides is probably not something I would have
wanted to do myself.
Title: Re: atmega1284 programming from a 328 chip
Post by: pito on Jan 30, 2013, 08:16 pm
FYI - This is how the 115kbaud signal (ie. 0xAA, 0x55 sent) looks like at the 1284p' Rx input when passed via 220kohm serial resistor with 100pF to ground (the "RC filter"). Hard to recommend, though.. The same with 10k pullup on the Rx input. The same with 10kohm serial.. And a picture when connected directly w/o the "RC" filter (FTDI or BT output resistance assumed ~200ohm typically)..
Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 30, 2013, 09:21 pm
10K series-R with 100 pF to gnd looks like the winner, if wanting to make a reasonable
low-pass filter on RX0.

For reference, you might try the 220K series-R *without* the 100 pF to gnd, and no pullup.
The first and second waveforms here are useless. The first is basically like smoothing out
a PWM signal to produce a d.c. level, and in the 2nd, the output is too tiny.
Title: Re: atmega1284 programming from a 328 chip
Post by: pito on Jan 30, 2013, 10:16 pm
Basically I would not recommend to put 220k in series even w/o the cap for such speeds..
Title: Re: atmega1284 programming from a 328 chip
Post by: oric_dan on Jan 30, 2013, 11:11 pm
Looks about right. Estimated capacitance to gnd, from T.C. = 63% of swing, is approx
C = 2.5usec/220K = 11.5 pF. Spot on. Slow, but much better than with the 100pF on
there.
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 31, 2013, 09:34 pm
Must admit all that with the graphs went over my head :)

I now have another issue, and would welcome comments.

I've breadboarded the chip neatly, and tested it using the example blink and fade examples - worked fine.  I then breadboarded the 1307 RTC chip and uploaded the sample code below (found on this forum)

Code: [Select]

/*
*
* Read and set through serial port demo sketch for DS1307 I2C rtc clock
*
* DS1307 library provided by mattt & D.Sjunnesson, corrected by bricofoy.
* See DS1307.h for more details.
*
* This exemple code is under GNU GPL
*
* (c) bricofoy 2012
*
*/



// This is for compatibility with both arduino 1.0 and previous versions
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

#include <Wire.h>
#include <DS1307.h>

void setup() {
  Serial.begin(9600);
  use();
  read_RTC();
}


// use explanation message
void use() {
  Serial.println("\nUSE      : u U r R h[00-23]m[00-59]s[00-59]j0[1-7]D[01-31]M[01-12]A[00-49]");
  Serial.println("\nEXEMPLE  : h09m35d03 set time to 09h35 and day of week 3 (thuesday).");
  Serial.println("\nCommands : h** : hour,  m** : minutes, s** : seconds, d0* : day of week");
  Serial.println("           M** : month,  Y** : year,   D** : day of month.");
  Serial.println("           r stops clock, R starts it. ");
  Serial.println("           u or U shows this message, all other caracter shows time.");
}

// DS1307 time read function
void read_RTC() {
  Serial.print("\nActual time : ");
  Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
  Serial.print(":");
  Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
  Serial.print(":");
  Serial.print(RTC.get(DS1307_SEC,false));//read seconds
  Serial.print(" ");                 // some space for a more happy life
  Serial.print(RTC.get(DS1307_DOW,false));
  Serial.print(" ");
  Serial.print(RTC.get(DS1307_DATE,false));//read date
  Serial.print("/");
  Serial.print(RTC.get(DS1307_MTH,false));//read month
  Serial.print("/");
  Serial.println(RTC.get(DS1307_YR,false)); //read year
}

// set clock values
void write_RTC() {
      char value=0;
      char command=0;

      command = Serial.read();
      delay(50); //delay to allow good serial port reading
      value=byte((Serial.read()-48)*10); //-48 becaus ASCII value for 0 is 48, 1 is 49, etc and *10 because we read tens first
      delay(50);
      value+=byte((Serial.read()-48)); //and then we read units

      switch (command) {
case 'h' :
  RTC.set(DS1307_HR,value);
  Serial.print("hours set to ");
  Serial.println(value,DEC);
  break;
case 'm' :
  RTC.set(DS1307_MIN,value);
  Serial.print("minutes set to ");
  Serial.println(value,DEC);
  break;
case 's' :
  RTC.set(DS1307_SEC,value);
  Serial.print("seconds set to ");
  Serial.println(value,DEC);
  break;
case 'D' :
  RTC.set(DS1307_DATE,value);
  Serial.print("day of month set to ");
  Serial.println(value,DEC);
  break;
case 'd' :
  RTC.set(DS1307_DOW,value);
  Serial.print("day of week set to ");
  Serial.println(value,DEC);
  break;
case 'M' :
  RTC.set(DS1307_MTH,value);
  Serial.print("month set to ");
  Serial.println(value,DEC);
  break;
case 'Y' :
  RTC.set(DS1307_YR,value);
  Serial.print("year set to ");
  Serial.println(value,DEC);
  break;
case 'u' :
case 'U' :
  use();
  break;
case 'r' :
  RTC.stop();
  Serial.println("Clock stopped");
  break;
case 'R' :
  RTC.start();
  Serial.println("Clock running");
  break;
default :
  break;
      }
      read_RTC();
}

void loop() {
   if (Serial.available()) {
     write_RTC();
    }
}



This is (if I ready the details correctly) will display the date / time via the serial monitor, which is fine as I don't have an LCD hooked up yet.  The code compiled and loaded without error, but when I launched the serial monitor I got the message that the port was in use and I needed to close other applications.  So I tried uploading the basic blink example and got the same message... it seems that the code running won't free up the com port :(

Any suggestions ?

Malcolm
Title: Re: atmega1284 programming from a 328 chip
Post by: malc-c on Jan 31, 2013, 09:43 pm
belay that - re-boot the PC and all is well