Using ICSP and SD Board on SPI pins

Greetings fellow hackers,

I have run into another problem with my BASIC pocket computer project. I'm using a Atmega644v in it's own circuit. I've got it all soldered together and everything works apart from thing: The ICSP header. I put one of these in so that I can still update the software on the chip even when it's fitted into it's soon-to-be-printed 3D case. The problem is that when i hook up the 4 jumpers from the 6-way header to my arduino and try to upload code, I get the

Yikes!  Invalid device signature. error

My assumption is that the SD card is interfering, (link to SD board) since it is on the SPI pins as well. So my question is: Can anyone point my in the right direction as to how to have an ISCP header as well as other components on the same SPI bus.

There is a similar topic on this forum about the subject but it only has my response on it:
Problem using ICSP/SPI 6-pin header on DUE to interface with SD Card

I've also done a bit of googling and found this thread on the AVR Freaks forum which had some interesting info:
AVR forum - Can I reuse ISP pins for other tasks?(Target: Atmega164p)

I'm pretty sure my answer lies somewhere in there, but the bit relating the SD cards suggests putting in a pull-up resistor on the CS line.

You just make sure that each /CS has an external pull-up resistor. Whenever /CS is high, all the device pins are in 3-state.

Which doesn't make any sense to me seeing as there is no switch or button on that line.

It also talks about using isolation resistors,

they will need to be connected to that other function by way of a 4.7K (or something similar) isolation resistors.

but Adafruit says that you should not use resistro dividers on the 3.3V logic lines.

keep wires short, and avoid using resistor dividers for the 3.3V logic lines.

(are they the same thing?) They say to use a 4050, but there's another contradiction as the AVR Freak guys say not to use a 4050.

Since some bright spark chose to put the 4050 in the way

So as you can see, I'm a little confused and some clarification would be nice.

Any input would be appreciated.
Thanks in advance,
FactualOrc.

You might get that error is you are using the ArduinoISP sketch and don't disable Auto Reset. If avrdude resets the Arduino it will be talking to the Arduino's bootloader instead of the ArduinoISP sketch. The bootloader will return the signature for an ATmega328P when you are expecting the signature for your ATmega644V.

Could it be as simple as just fixing the signature bytes being called out?
ATmega644 0x1E 0x96 0x09
ATmega644A 0x1E 0x96 0x09
ATmega644V 0x1E 0x96 0x09
ATmega644P 0x1E 0x96 0x0A
ATmega644PA 0x1E 0x96 0x0A
ATmega644PV 0x1E 0x96 0x0A

If you think the SD card is interfering, make sure you have a pullup on the Arduino pin that drives the SD chip select pin (before any buffer chip if you have one) so that when reset is pulled low by the programmer and the Arduino IO pins go into high impedance mode (i.e. floating) the CS pin is high.

You say 4 jumpers on 6-pin header - which are you leaving off? MISO-MOSI-SCK-RESET-GND are all required, and most programmers either provide 3.3V or 5V to the board being programmed, or else monitor the supply pin and adjust the levels they drive to match (Atmel MKii for example).

You might get that error is you are using the ArduinoISP sketch and don't disable Auto Reset.

Ok, I tried adding the 120 Ohm resistor (5 x 22 Ohm + 10 ohm... I didn't have a 120 one) but that didn't seem to make a differnce. I managed to enable arduinoisp.force so here is the error log

Binary sketch size: 25,814 bytes (of a 63,488 byte maximum)
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA644 is 1E 96 09
avrdude: verification error, first mismatch at byte 0x0000
         0x0c != 0x00
avrdude: verification error; content mismatch

Could it be as simple as just fixing the signature bytes being called out?

I'm not sure what you mean here but according to the error log it seems to have the signature right.

make sure you have a pullup

I'll try this next. I have the SD board hooked up to +5v but i'll hook the CS up to +3.3v as per Adafruits instructions. Will I use a 10K resistor?

which are you leaving off?

The Pocket Computer is powered by its own battery and I'm using an arduino uno as the programmer so I've left the +5v pin and the GND pin disconnected. Is this right?

FactualOrc:
avrdude: Expected signature for ATMEGA644 is 1E 96 09

Could it be as simple as just fixing the signature bytes being called out?

I'm not sure what you mean here but according to the error log it seems to have the signature right.

I think avrdude just shows the signature it was expecting, not the one it received. To find out what it actually received you have to turn on verbose upload logging and sort through the log.

FactualOrc:

which are you leaving off?

The Pocket Computer is powered by its own battery and I'm using an arduino uno as the programmer so I've left the +5v pin and the GND pin disconnected. Is this right?

Nope, you need GND pin also, as a voltage reference for the i/o pins.

Ok, I'm really stumped now, I've disconnected the DI, Do and CLK lines from the SD board (the ones going into the SPI bus) and I still get the Yikes! Invalid device signature. error.

I have the 120 ohm resistor for disabling auto reset and I have all 6 lines from the header connected into the arduino (I've disconnected the battery but can I leave it in and just leave the power switch off?)

I think avrdude just shows the signature it was expecting, not the one it received. To find out what it actually received you have to turn on verbose upload logging and sort through the log.

I've turned on verbose-on-upload but the important information seems to be at the top and when the it's finished and told me that it hasn't worked, It has cut off the bits at the top because the buffer size is too small and the log is too big. Does anyone know where it saves it externally?

FactualOrc:
I have the 120 ohm resistor for disabling auto reset and I have all 6 lines from the header connected into the arduino (I've disconnected the battery but can I leave it in and just leave the power switch off?)

Close, but the reset pin from the target m644v needs to go to pin D10 (not the 6-pin header) on the Arduino as ISP.

Oh wait, did you mean the from 6-pin header on your target board to what pins on the Arduino as ISP? Can you show what pins are connected to what pins?

Close, but the reset pin from the target m644v needs to go to pin D10 (not the 6-pin header) on the Arduino as ISP.

That was the most confusing thing I have ever read but your edit helps to clarify.

I'm not connecting anything to the ISP on the arduino The 6 pin header I am referring to is the one I have soldered on to my perfboard which has all the components and electronics for the Pocket Computer

I'm connecting:

header arduino uno
pin 1 (MISO) to Pin 11
pin 2 (VTG) to +5v
pin 3 (SCK) to pin 13
pin 4 (MOSI) to pin 12
pin 5 (RST) to pin 10
pin 6 (GND) to GND

You can increase the size of the status area at the bottom of the IDE window - move the mouse slowly over the dividing line until you see the double-arrow cursor - make the bottom bigger by dragging it up. Then you can scroll up & down within it.
The info shown there can all be copied - so much that it can be more than you can post here.
Go up to part after the code compiles, where it says "Compiled xxx of xxx bytes", and see if there is message about the device signature it actually sees.

FactualOrc:
I've turned on verbose-on-upload but the important information seems to be at the top and when the it's finished and told me that it hasn't worked, It has cut off the bits at the top because the buffer size is too small and the log is too big. Does anyone know where it saves it externally?

If you are under Windows XP, it will be something like,
C:\Documents and Settings\User\Local Settings\Temp\console35478281018359143.tmp\stderr.txt

Here is a pastebin of the error log.

Link

I'm actually getting a tad stressed out at this point and am thinking about giving up =( but thanks for all your help so far; you're really a nice a bunch of people :slight_smile:

FactualOrc:
Ok, I'm really stumped now, I've disconnected the DI, Do and CLK lines from the SD board (the ones going into the SPI bus) and I still get the Yikes! Invalid device signature. error.

The first thing the ISP (ArduinoISP) is asked to do is get the signature. If the MOSI pin is not connected the command to the chip to return the signature will not get through and the chip won't return a valid signature. If the MISO pin is not connected the signature can't get back to the ISP. If the SCK pin is not connected then no data will move in either direction. In all cases avrdude will report "Invalid device signature.".