6

I'd like to program an ATmega1284p with my AVR Dragon and the Arduino IDE. So far I have installed mighty1284p (http://maniacbug.wordpress.com/2011/11/27/arduino-on-atmega1284p-4/), after writing my (example) sketch I compile it using the Arduino IDE and then cd into the (temporary) directory the sketch is build in. It contains the .hex file, as seems logic.

I then upload the .hex file onto the 1284 using the Dragon and avrdude, that too seems to work fine.

Except on my breadboard the 1284 does - nothing. No blink on pin 13 (or any other pin for that).

The fuses have been set to use the internal RC oscillator with 65ns startup time. The supply voltage is +5V/GND, measured ok.

This is my breadbord-setup. Between VCC and GND I have a 20pF capacitor as per the Atmel instructions.

schematic

simulate this circuit – Schematic created using CircuitLab

Any ideas what I am doing wrong here?

Edit 1 I am trying to make the Blink example from the Arduino IDE work:

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
 */

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 1;

// the setup routine runs once when you press reset:
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}

The barebones avr-gcc example that does work I keep jabbering about in the comments is this one:

#include <util/delay.h>
#include <avr/io.h>

#define F_CPU 1000000

int main (void) {
  DDRB  = 0xff;
  while(1) {
    PORTB |= (1<<PB1);    //Bit setzen
    _delay_ms(1000);       // halbe sekunde warten
    PORTB &= ~(1<<PB1);   // Bit loeschen
    _delay_ms(1000);       // halbe sekunde warten
  }
 return 0;
}

I have successfully uploaded this program's .hex and the uC does blink on Pin2 as it should, the rest of PORTB is HIGH the while (again, as it should be). So I assume the wiring, power and my n00b avrdude skills are, well, sufficient. I'd just like to use the Arduino's bequem language constructs... (bequem is german for "convenient, comfortable" - as in "I don't think about buying new shoes, mine are quite bequem!" ;)

Edit 2 What would I do without you guys ;)! I haven't learned this much in one evening since a long time.

Sometimes just talking about it helps tremendously in tearing down one's brain-barriers.

I have set the fuses on my 1284p to use the internal RCO plus I've set the fuse to divide the clockrate by 8. Evey I should have been able to do that math in my head, the clockrate is now 1MHz. mighty1284p in it's original settings want's aclockrate of 16MHz, so everything was just sooo slow that I thought it didn't work at all, when in fact it was just crawling.

Working setup so far:

Arduino IDE with mighty1284p, I added this to the boards.txt of mighty1284p:

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

mighty_opt8.name=Mighty 1284p 8MHz using Optiboot
mighty_opt8.upload.protocol=arduino
mighty_opt8.upload.maximum_size=130048
mighty_opt8.upload.speed=115200
mighty_opt8.bootloader.low_fuses=0xff
mighty_opt8.bootloader.high_fuses=0xde
mighty_opt8.bootloader.extended_fuses=0xfd
mighty_opt8.bootloader.path=optiboot
mighty_opt8.bootloader.file=optiboot_atmega1284p.hex
mighty_opt8.bootloader.unlock_bits=0x3F
mighty_opt8.bootloader.lock_bits=0x0F
mighty_opt8.build.mcu=atmega1284p
mighty_opt8.build.f_cpu=8000000L
#mighty_opt8.build.core=arduino:arduino
mighty_opt8.build.core=standard
mighty_opt8.build.variant=standard

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

mighty_opt1.name=Mighty 1284p 1MHz using Optiboot
mighty_opt1.upload.protocol=arduino
mighty_opt1.upload.maximum_size=130048
mighty_opt1.upload.speed=115200
mighty_opt1.bootloader.low_fuses=0xff
mighty_opt1.bootloader.high_fuses=0xde
mighty_opt1.bootloader.extended_fuses=0xfd
mighty_opt1.bootloader.path=optiboot
mighty_opt1.bootloader.file=optiboot_atmega1284p.hex
mighty_opt1.bootloader.unlock_bits=0x3F
mighty_opt1.bootloader.lock_bits=0x0F
mighty_opt1.build.mcu=atmega1284p
mighty_opt1.build.f_cpu=1000000L
#mighty_opt1.build.core=arduino:arduino
mighty_opt1.build.core=standard
mighty_opt1.build.variant=standard

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

Now my Arduino IDE has new boards: Mighty 1284p 1MHz using Optiboot and Mighty 1284p 8MHz using Optiboot which addresses/uses/references the internally available clockspeeds.

Now avrdude needs to set the fuses:

avrdude -c dragon_pp -P usb -p m1284p -U lfuse:w:0x62:m -U hfuse:w:0x99:m -U efuse:w:0xFF:m -U lock:w:0xFF:m

I can't do this in my head, nor do I knew much about this. But the interwebs help a poor man out here, too: http://www.frank-zhao.com/fusecalc/fusecalc.php?chip=atmega1284p yields the above.

Then it is a simple matter of looking at Arduino's output, cding into the directory and uploading the ready-built .hex:

cd /var/folders/px/xmf1dygn6p5_fn1hh05c6gyr0000gn/T/build4082512148637729777.tmp/
avrdude -p m1284p -c dragon_pp -P usb -U flash:w:Fade.cpp.hex

(and yes, I have silently upgraded my trials to something more daunting, like the Fade example. It works.

Now all that is left: How would I use the AVR Dragon's HVPP directly from within the Arduino IDE? I have added a section to programmers.txt as such:

dragonpp.name=AVR Dragon HVPP
dragonpp.communication=usb
dragonpp.protocol=dragon_pp
dragonpp.force=false

which I assumed would be correct for the above avrdude parameters, but for now the IDE keeps asking me for a port (as in /dev/tty.usbAF65de) which of course the Dragon doesn't have, the correct -P option for avrdude is simply usb (which, see above, works if done manually).

Any further ideas on how to add the AVR Dragon's High Voltage Parallel Programming to Arduino?

Christian
  • 621
  • 12
  • 22
  • 2
    While the ASCII diagram is better than none, this site has a somewhat usable schematic editor integrated into it, Circuit Lab. You can invoke this editor by using Ctrl-M while editing your post. Please consider replacing the ASCII art with a schematic. – Anindo Ghosh May 18 '13 at 14:05
  • Thanks for the tip - hope I have done everything right. The editor is a bit of a, well, struggle under OS X and Chrome... But a fine tool nevertheless. – Christian May 18 '13 at 14:32
  • are you sure the polarity of D1 in the schematic above is correct? If you want pin20 to be able to turn the LED on you need it to go the other way. – Gorloth May 18 '13 at 16:54
  • @Gorloth You're correct, I'm just bad with Circuit Lab. I have it in the correct way on my board. – Christian May 18 '13 at 17:08
  • What is the purpose of R1? Furthermore, the diagram as shown should blink arduino digital pin 14, not 13. – microtherion May 18 '13 at 18:35
  • Does ATmega1284p really only have a single Vcc and a single GND connection? You should really should connect AVCC (= +5V) and the other GND pin too. – jippie May 18 '13 at 19:13
  • Did you connect 20pF or 20uF? At least use a separate 100nF capacitor across the controller's Vcc and GND, as close to the controller's pins as possible. – jippie May 18 '13 at 19:16
  • You changed the fuses, can you still program your AVR? – jippie May 18 '13 at 19:17
  • What is the exact program you flashed into the AVR? – jippie May 18 '13 at 19:19
  • @microtherion I got that one from the app notes, it works without though (as I just noticed from a barebones No-Arduino-Things-Involved example I tried). – Christian May 18 '13 at 19:20
  • @jippie 20pF of course, my bad. That drawing of mine gets worse and worse. I can set the fuses with the HVPP on the Dragon AVR. I have tried powering AVcc and it's GND, too, no avail. The barebones example work without them being connected. Don't I just need those if I do anything with the analog in/out's? Using the Arduino IDE I flashed the Blink example, the barebones example is at http://pastebin.com/jRJi3i9G – Christian May 18 '13 at 19:22
  • Please add the source program to your question and change 20pF to 100nF or put them in parallel if you insist on keeping to 20pF – jippie May 18 '13 at 19:23
  • You have to figure out the mapping between Arduino pin numbers and AVR pin numbers. Not sure if they are defined for an 1284 though. – jippie May 18 '13 at 20:21
  • Why do you want HVPP? – jippie May 18 '13 at 20:23
  • Maybe you should clean up your question a bit and make the title more current. You probably should have made a separate question somewhere along the line ... – jippie May 18 '13 at 20:24
  • @jippie The same occured to me. I will do that. I want HVPP because I'd like to only use one programmer in the future, retiring my proven USBasp clone. With the Dragon's HVPP I can easily reset fuses, and that saved my *ss a few days ago when using `mighty1284p` with the USBasp somehow disabled my 1284 by setting fuses strangely. – Christian May 18 '13 at 20:33
  • Sorry for overdoing this question, I have opened another containing just the "Adding a new programmer"-part at http://electronics.stackexchange.com/questions/69752/adding-the-avr-dragons-hvpp-to-the-arduino-ide . Thanks for pointing that out to me. – Christian May 18 '13 at 20:51
  • After burning the bootloader, have you tried to use the option 'Upload using Programmer' in the file menu – Hemal Chevli Sep 14 '13 at 04:28
  • This question appears to have been [abandoned](http://meta.electronics.stackexchange.com/questions/2480/whats-the-policy-on-abandoned-questions) - whilst a good answer may be possible (and may even be hidden somewhere in the edits to the Q, the added refs and comments) - I doubt one will ever be written and accepted. We should bury our dead. – RedGrittyBrick Nov 14 '13 at 15:21

1 Answers1

2

Before we bury this question I'd like to come back to my forgotten child.

Short answer: The dragon was faulty, an exchanged unit worked just fine. Thereafter I somehow totally forgot to close this question. I'm sorry.

Christian
  • 621
  • 12
  • 22