SD card and In System Programming. Hardware setup?

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am working on a home made bike computer. I have a Mega664 and a load of peripherals eg lcd, i2c rtc, polar HR reciever i2c barometer, uart (debuging) and wheel, crack and button inputs all these are working OK.

I have added an SD card using the futurlec mini board and I can get it to work so long as I do not have the SPI connected up to my Dragon at the same time. The Dragon only works reliably if I have the SD disconected. I have tried various combinations of series resistor to get both working together but have not got it reliable although I have got close enough to think it must be possible.

The one thing that I have that is slightly unusual is that there are two seperate 3.0V power suplies. One for the mega and rtc and one for all the other peripherals. The mega controlls this secondary suply so I can shutdown when idel. I was hoping this would help as when in reset the secondary suply to the SD card is off.

Anyone know if this should work? What would be the recomended conection setup?

Ifor

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't think this can be done. AVR042 talks about connecting ISP lines so that the SPI device doesn't interfere with the programmer. This, as you probably already know, is done by adding resistors in series with the SPI bus lines, but "outside" the ISP connections. These resistors give signals to/from the ISP priority over those to/from the SPI bus. Short of adding a switch between the two, I don't think you're going to be able to give priority to "both".

Michael

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cutting the power supply from SD card does not mean it is magically absent from the shared bus. On the contrary. Usually devices have protection diodes on data buses to supply and ground, so basically anything feeding 3V to datain, clockin or chipselectin on the memory card will actually try to power the card and anything on it's power supply pins via data bus.

You propably would get better results if you just leave card power on, card chipselect off (high) and then use the programming interface. Read card datasheets if the dataout pin is really disabled when chipselect is off.

If that does not help, use a buffer on SPI pins so that you can disable the card section of the bus when programming, change card to different pins and bit-bang software SPI bus for the card.

Or write a bootloader which reprograms the avr from a binary file on the memory card. No need to use ISP while card is in then.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for that.

On my breadboard setup I have changed the aux power controll pull-up to a pull-down so I keep power to the SD card in reset. I have added a pull-up to ssel input to the card so the card should not get selected in reset. That has got the dragon working with the card pluged in but the card itself still was not working with the dragon pluged in. I have now added 470 ohm resistors in series with the programing interface leaving the card connected directly and both sides look to be working with the other half pluged in. I will go with this for my next prototype which I am putting on a strip-board. I can actualy get on a real bike with it and the real software fine tuning will start.

I will consider the bootloader option for the future being able to do a software upgrade without the dragon has potential benifits and its another thing to learn.

Ifor

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well then it looks like the Dragon programmer does not release the bus into high-impedance state. I don't know if it should, but I thought all real programers do and cheap ones don't.

Adding a buffer to isolate either Dragon or memory card would do the trick.

I have always hated why SPI is shared with programming pins - except when programming was shared with USART (and SPI clock), I hated that too.