Go Down

Topic: Dumping firmware/software...and/or reflashing?? (Read 27 times) previous topic - next topic

Coding Badly

Any ideas why the Atmel route would not recognize the chip until Arduino wrote something to it?


Purely coincidence.

Quote
How do I initialize virgin chips?


No need.  AVR processors come from the factory ready-to-run at 1 MHz.  The Flash memory is filled with 0xFFFF which is an illegal opcode.  Illegal opcodes are executed as NOPs (details here... http://support.atmel.com/bin/customer.exe?=&action=viewKbEntry&id=227 ).  Apply power and the processor starts executing code that does nothing.

In other words, all you have to do to "initialize" the processor is upload a program.

Quote
The Arduino Uno as an ISP did something.  I can't say what exactly, but once I configured the Arduino to be an ISP (uploaded the ArduinoISP sketch and changed some settings in the IDE),


Which settings?

Quote
I was able to deploy to my test ATTiny44.  To test my deployment, however, I hooked up an LED to one of the pins and got nothing (I deployed the blink sketch).  I changed the blink program to turn multiple pins on and off just in case I got the wrong one on the board.  Still nothing. 


What board was selected when you uploaded?

mikedehaan

Ah Ha!  Success!    I had the circuit correct, but the arduino code wrong ::facepalm::

I hooked up the Arduino as an ISP and deployed a new version of blink and it worked.  The Arduino API refers to pins differently than I would have expected, but with a small modification to the blink program, I was able to have the chip tell me which pin had which number.  For example, Pin 3 is actually Pin 9 for the Arduino API.  So I think my first version of blink was trying to tell the GND pin to blink (or something just as stupid).


Which settings?


There was a parameter in the heartbeat() method of ArduinoISP that needed to change.  The instructions on one site said to change the delay(40) call to delay(20).


What board was selected when you uploaded?


I selected the ATtiny44 board which is only available after downloading the ATtiny addons for Arduino.  For anyone interested, I followed these turotials:

http://hlt.media.mit.edu/?p=1695

http://hlt.media.mit.edu/?p=1706

Here's my modified version of Blink.  It will cycle through all the pins on the ATtiny44 and blink the number of times indicating which pin it is:

Code: [Select]

void setup() {               
  for (int i = 0; i < 12; i++) {
    pinMode(i, OUTPUT);
  }
}

void blinkPin(int pin) {
 
  for (int x = 0; x <= pin; x++) {
    digitalWrite(pin, HIGH);
    delay(20);
    digitalWrite(pin, LOW);
    delay(20);
  }
  delay(50);
}

void loop() {
  for (int i = 0; i < 12; i++) {
    blinkPin(i);
  }
}


One problem I still have is, the delay method seems to be running slow.  I tried a delay of about 100 (which should be 100ms or 0.1 seconds) which resulted in about a 1 second delay.  In the Atmel AVR Studio, you can set the F_CPU value to indicate to delay how fast your clock is.  Is there something similar in Arduino that might be causing my delay method to run slow?

Thank you so much for your help by the way.  I sincerely appreciate it.

Coding Badly

I hooked up the Arduino as an ISP and deployed a new version of blink and it worked. 


Excellent.

Quote
The Arduino API refers to pins differently than I would have expected,


Should be top-left to top-right in a U-shape around the processor.  That's how the pins on the Uno (ATmega328 based boards) are numbered.

Quote
One problem I still have is, the delay method seems to be running slow. 


The program is compiled for 8 MHz and the processor is configured to run at 1 MHz.  I suggest using this core...
http://code.google.com/p/arduino-tiny/

I added two ATtiny44 entries for you.  Use this download...
http://code.google.com/p/arduino-tiny/downloads/detail?name=arduino-tiny-0100-0013.zip

Start with the ATtiny44 @ 1 MHz  (internal oscillator; BOD disabled) board entry.  After re-uploading, your program should blink correctly (±10%).

When you are comfortable everything is working correctly, select ATtiny44 @ 8 MHz  (internal oscillator; BOD disabled) then execute Tools / Burn Bootloader.  That will change the fuses (reconfigure the processor) to run at 8 MHz.  Even though the processor is running 8x faster, after re-uploading, your program should still blink correctly (±10%).

Running at 1 MHz is a great choice for battery power.  Running at 8 MHz is a great choice if you need the extra horsepower.

Quote
Thank you so much for your help by the way.  I sincerely appreciate it.


You are welcome.

mikedehaan

Just to confirm the chip, I was able to hookup (briefly) to the Paintball gun circuit and the device id matches the id of a brand new ATtiny44A from Atmel.

Phenom Device ID: 0x1E9207
ATtiny44A Device ID: 0x1E9207


Coding Badly


Helpful tip: It is possible to download a binary version of the program from the Paintball gun.  You may want to do this early in your project so you have a backup.

Great news about the processor.  That will make your development effort go much more smoothly.

Go Up