Go Down

Topic: Help in programming the Atmega1284 with maniacbug-mighty-1284p. (Read 83094 times) previous topic - next topic


Feb 02, 2013, 12:17 pm Last Edit: Feb 02, 2013, 01:25 pm by pito Reason: 1
FYI - a simulation - signal from FTDI to the Rx pin, and Rx coupled via a parasitic capacitance to the XTAL1 pin of the 1284p's oscillator. For 3 parasitic capacitances - 1pF, 5pF, 10pF. You may see the effect on the frequency when the rising edge of the Rx signal comes in. May behave differently - depends on the gate (here 4011 gate model used), xtal (??), etc. parameters used.

Disclaimer: this is only a simple simulation with parts with different parameters as the 1284p probably includes. For demonstration purposes only. No warranties of any kind.


Feb 02, 2013, 12:55 pm Last Edit: Feb 04, 2013, 12:55 am by pito Reason: 1
And the same for 5pF parasitic capacitance between the pins and 200ohm (no resistor), 10k, 200k serial resistor. It seems the 200k does not create a glitch in the oscillation (in this simulation).

Disclaimer: simple simulation only, with different parts as included within 1284p. For demo purposes only. No warranties of any kind.

PS: The very bottom picture is probably the most realistic simulation out of all above- with 4049 inverter simulating the 1284p oscillator with more power (full swing), and 10pF capacitance between the RX and XTAL1 pins. The oscillator period changed from 127.1ns to 135.4ns after the Rx' rising edge (thus the frequency)..


With Low Fuse= F7 (Full Swing Oscillator 16K CK + 45ms) I cannot reproduce the upload errors anymore (the 10k serial resistor is not needed). It could be the 1284p operated @16MHz and 3V3 needs full swing (more power), otherwise the nearby RX pin may influence (modulate) the crystal oscillator frequency (especially with the DIP package with larger capacitance between the pins) and it comes to errors then..
PS: XTAL1 pin13 (RX is 14) - is the input of the crystal oscillator (high impedance, easy to modulate), would be better to have XTAL2 pin - the oscillator output - there (low impedance, harder to modulate)..

Huh! It's extremely cool that you've been carrying on with this problem while the rest of us have
been sleeping!

I don't know anything about USBasp or the ATmega fuses, and can barely understand the
convoluted description of the latter in the 1284 d/s, but you may have solved the problem.
Ref Table 9-1, maniacbug's boards.txt setup uses the low-power oscillator, low fuses = 0xFF,
instead of full swing oscillator, low-fuses = 0xF7 and there lies the RX0 sensitivity problem.
Plus, possibly the XTAL1 is in the wrong place.

Sheesh, can this endless muckup on 7 continents be that simple? !!!


Feb 03, 2013, 07:39 pm Last Edit: Feb 03, 2013, 08:58 pm by pito Reason: 1
I am using it just now w/o the resistor on a noisy breadboard with F7 and it works fine, no issues yet.. ;)

BTW, the 328p arduinos are lucky not to be affected by the issue as well as the Rx and Tx pins are far away off the XTAL1 pin. Moreover, XTAL1 (the critical sensitive crystal oscillator input) is flipped around against the 1284p and close to GND - GND acts as a shielding (GOOD)! See below..

IMHO the issue severity depends on the design (parasitic capacitance), crystal parameters, 2 crystal capacitors values, and how off is the actual crystal frequency from the recommended ie for 115k2:
Code: [Select]
8MHz crystal
57k   3.7% error
115k 7.8% error
16MHz crystal
57k   2.1% error
115k 3.7% error

Thus even a small additional error introduced ie. by such frequency pulling by Rx signal edges may disturb the Uart communication easily..
That is my current understanding  :P If Atmel plans a new die revision, I would recommend them to swap the oscillator pins, my invoice will follow :)


Good analysis, I think. Funny how Atmel flipped XTAL1,2 around between the 328 and 1284.
Also, 2.1 and 3.7% errors are on the edge of reliability, AFAIAC.


Feb 03, 2013, 08:38 pm Last Edit: Feb 03, 2013, 08:48 pm by pito Reason: 1
BTW - hand wired constructions usually have less parasitic capacitances as the PCBs do..
BTW2 - the capacitance between two adjacent rows on a solder-less breadboard is around 3.5pF..


Feb 03, 2013, 11:06 pm Last Edit: Feb 03, 2013, 11:32 pm by tack Reason: 1
I've been uploading to my 1284P via ICSP due to this problem, even just a 23k sketch failed every time via the bootloader and serial.

I've just re-burnt the bootloader and tried the same sketch 3 times and it failed.

I added the 10k series resistor on RX0 and tried again and it worked!

Tried it 6 times and it uploaded 100%.

Removed the 10k resistor and it failed.

Replaced the resistor and it worked 3 times in a row again.

I'll now try re-burning the fuses with the 0xF7 low bit and report back.

EDIT: Used Nick's Bootloader Programmer (for the first time) to re-burn the bootloader and set the fuses (I changed Low Fuse from 0xFF to 0xF7 in his sketch) and retried the upload with no resistor. It worked! Now I just need a big sketch to verify it really.

The most profound thanks to you guys for working together to track down and find a solution to this problem. Ye, you can upload via ICSP, but when your board is in a device that means you have to take everything off the SPI bus. On the board I just had made I actually included a 4 pin DIP switch so I could separate everything else form the ICSP header for any code updates that needed to be programmed. I also have a serial header available as well.

Right, now it appears that the 644P family is in the sketch to be identified but there is no entry for a bootloader or fuses setup. Does anyone know how we might go about adding 644P support?


Feb 03, 2013, 11:31 pm Last Edit: Feb 04, 2013, 12:13 am by pito Reason: 1
Enclosed 127kB large sketch. Not to be run, just for upload tests.

EDIT: deleted - please use the BLINK sketch below..


Enclosed 127kB large sketch. Not to be run, just for upload tests.

Thanks for that, but I can't compile and upload as it needs some libraries; NilTROS, NilAnaolg, NilSerial and SDFat

SDFat I can get, but I can't find the others at all so I'm guessing they are ones of your own?


Feb 03, 2013, 11:41 pm Last Edit: Feb 03, 2013, 11:42 pm by pito Reason: 1
But you may take ANY sketch you have handy - just copy and paste those LARGE
Code: [Select]
byte PROGMEM atmega2560_v2 [] = {
0x0D, 0x94, 0x89, 0xF1, 0x0D, 0x94,

bla-bla stuff from the sketch I posted in it.. You can easily make 512kB sketch from it if you like :)


Feb 03, 2013, 11:58 pm Last Edit: Feb 04, 2013, 12:47 am by pito Reason: 1
This BLINK compiles 129,948 bytes. You have to have SdFat lib there.
Not for running, just for compile and 1284p upload test..
Remove your SDCARD when playing with it..
No warranties of any kind. Use at your own risk.. :P
Code: [Select]
Binary sketch size: 129,948 bytes (of a 130,048 byte maximum)


I managed to find the libraries to use your sketch.

O...M...G...It works!! 127k Sketch uploaded several times.

Fantastic work.


Feb 04, 2013, 12:12 am Last Edit: Feb 04, 2013, 12:16 am by retrolefty Reason: 1

Right, now it appears that the 644P family is in the sketch to be identified but there is no entry for a bootloader or fuses setup. Does anyone know how we might go about adding 644P support?

I have a optiboot version working on a 644P Bobuino board. I just used my USBtiny to burn the bootload, but the arduinoISP sketch should work also from the IDE once you have the bootloader saved in the correct folder and make the boards.txt entry.

Code: [Select]


And here is the boards.txt entry for the 644P



bobuino644.name=Bobuino 644P optiboot




Feb 04, 2013, 01:09 am Last Edit: Feb 04, 2013, 01:24 am by pito Reason: 1

..and there lies the RX0 sensitivity problem.

To clarify a little bit - No, it is not the "RX0 sensitivity" problem. That is an urban myth..

RX0 is perfectly fine.

It is definitely the XTAL1-pin placement problem (crystal oscillator input) - and most notably a not good decision at Atmel not to follow ie. the 328p as far as the crystal oscillator pins layout is concerned..


lefty, where did you get this file? --> optiboot_atmega644p-4-5.hex

I think here:


from here:


The only bootloader I can't remember a source site from is the optiboot compiled for the mega1280 chip which I found only after several days of searching. But I finely did locate a copy somewhere and now all my mega1280 boards (both of them LOL) are working well with optiboot.


Go Up