Arduino Miro running ArduinoISP

Hello All,

Just got a arduino micro and thought I would load up the ArduinoISP and see if it will run. I've spend a good amount of time debugging the thing but could not get it to run correctly. I decided the first step is to get it working by programming another arduino board... so I have UNO here as the target device.

I found this post to be very helpful with Nick's sketch and his picture: http://arduino.cc/forum/index.php/topic,145549.0.html

I was able to get Nick's detection code running correctly... so I know the SPI is connected correctly. One thing I did change in his sketch was to use SS instead of PIN 10 since thats what the ArduinoISP uses. Unlike the uno, micro has a dedicated pin for this.

Ok... now for ArduinoISP part.

I can't seem to get the chip validate correctly. I keep getting 0x000000 as the device id.

If I stick this bit of code in the start_pmode, which gets called when the programmer is asked to go into programming mode. The LED on pin 13 turns on.

  spi_transaction(0xAC, 0x53, 0x00, 0x00);
  uint8_t ch = spi_transaction(0x30, 0x00, 0x00, 0x00);
  uint8_t ch2 = spi_transaction(0x30, 0x00, 0x01, 0x00);
  uint8_t ch3 = spi_transaction(0x30, 0x00, 0x02, 0x00);
  if(ch == 0x1E && ch2 == 0x95 && ch3 == 0x0f) {
   digitalWrite(LED_ST, HIGH);
  }

However... if I stick the code below in a function called universal, the led also turns on (disabling the above code). universal() gets called when avrdude sends the 'V' command.

  if(buff[0] == 0x30 && buff[2] == 0x00 && ch == 0x00) {
    digitalWrite(LED_ST, HIGH);
  }

When the ArduinoIDE (avrdude) asks for the manufacture id the SPI returns 0x00, but when I ask for the manufacture right after it goes into programming mode it returns the correct value 0x1E.

I have tried bunch of different things: including changing the SPI speed (Nick's code was doing /64 vs ArduinoISP was /128)... Also tried rewriting the SPI portion to use SPI.h...

avrdude command I'm running: avrdude -p atmega328p -P /dev/tty.usbmodem1421 -c avrisp -b 19200 -t -vvvv

Anybody have any suggestion?

I do have a digital logic analyzer some where around here too... maybe I'll try pulling that thing out later and see if its a timing issue.

Thanks!!

Anybody have any suggestion?

Wiring... http://arduino.cc/forum/index.php/topic,156863.0.html

If the wiring was wrong I would think this code would fail all to gether.

I’ve also verified that 0x53 gets pinged back correct in the initial transmission (per datasheet).

spi_transaction(0xAC, 0x53, 0x00, 0x00);
  uint8_t ch = spi_transaction(0x30, 0x00, 0x00, 0x00);
  uint8_t ch2 = spi_transaction(0x30, 0x00, 0x01, 0x00);
  uint8_t ch3 = spi_transaction(0x30, 0x00, 0x02, 0x00);
  if(ch == 0x1E && ch2 == 0x95 && ch3 == 0x0f) {
   digitalWrite(LED_ST, HIGH);
}

Try this.

http://arduino.cc/forum/index.php/topic,156863.msg1178400.html#msg1178400

Are you running on windows? If yes, using -c arduino instead of -c avrisp should get you further. See http://petervanhoyweghen.wordpress.com/2012/09/16/arduinoisp-on-the-leonardo/, most of that stuff is applicable to the Micro too.

Finally figured it out... Shouldn't of taken me this long to figure this out :(

The problem is SS is connected to RX LED. This isn't necessarily a problem, except the Serial library seems to pulse the Rx LED when it receives data. Which is a problem. This is why my code seems to work until I receive a byte from the Serial port.

The solution is to move the SS pin to another pin... which is the same thing hiduino's link shows.

To me this is a little weird because, this means if you're using Serial + SPI (slave), RX Led becomes unusable.

Anyway I'm glad I finally figured it out and hope it helps others.