4

I am using ATMEGA128 to communicate with another device. For this I am using SPI with ATMEGA128 as slave. I use SS, SCK and MOSI pins. The problem I am facing is that when I have to download program, I have to disconnect SPI pins. The ATMEGA128 module I am using uses TXD0, RXD0, SCK(PB1) pins to download program. Why am I facing this problem ? Is it because SPI and downloading circuit uses same SCK pins ? Is there any way to avoid disconnecting SPI pins ?

sujan_014
  • 516
  • 2
  • 8
  • 22

2 Answers2

1

Does the other device have a chip select input, or could you add one on its VCC pins? If so, you could tie this device's CS (active low) input to an extra AVR port pin with an external pull-up resistor attached (maybe 10k ohms or so), then set this AVR pin low at the start of your code somewhere. The device will be disabled by the external pull-up until programming of the AVR is finished and your code re-enables it when run.

bobasaurus
  • 129
  • 1
  • 9
0

Is it because SPI and downloading circuit uses same SCK pins ?

Yes, you have to prevent any other device from driving the SPI lines during programming.

Is there any way to avoid disconnecting SPI pins ?

Yes. To avoid driver contention, a series resistor should be placed on each of the three dedicated lines if there is a possibility that external circuitry could be driving these lines.

See my answer here.

Community
  • 1
  • 1
Rev
  • 5,827
  • 4
  • 27
  • 51