Go Down

Topic: SPI Programmer and how to isolate from ATtiny..... (Read 2248 times) previous topic - next topic

winneymj

Hi,
I am using the Arduino UNO and SPI to program a ATtiny84 on a breadboard.  My ATtiny is using the I2C interface to communicate with a real-time clock chip.  My problem is that I have to disconnect the ISP programming pins from the Arduino to the ATtiny to allow I2C to work.
I want to build a shield that I can plug into UNO and program the ATtiny (instead of breadboard) and leave the shield in place, for power etc, and still have the I2C interface work.  Not sure I am explaining this right but I am looking for the best way to isolate the programming pins from the UNO, so that I can run the ATtiny in-circuit.
It takes 4 pins to ISP program an ATTiny, so I could possible have a slider switch that I could switch over to disconnect the 4 pins after programming, but is there a better way or a more "electronic" way with a tact switch to isolate the pins.
Phew... Hope I am making sense.

Thanks
Mark Winney

johnwasser

Typically you would put an ICSP header on the board to be programmed.  Plug in the programmer to program.  Unplug it to run your program.

An alternative, if you are using a DIP processor, is to unplug it from your board and plug it into a socket/board set up for programming.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

winneymj

Thanks for the response.  I have seen that done, plugging, unplugging, but I was looking for a more elegant way.  For example if I want the ATtiny to communicate with UNO, I would be unplugging programmer pins between the Uno and ATtiny only the reconnect them again to the Uno in diff manner.  I would prefer to do neither and just hit a button/slide a switch and lo and behold by programmer pins are disconnected between Uno and ATtiny, and my shield is now running with ATTiny.
I would ideally like to program and run the ATTiny on a shield without all the plug/unplug.

Thanks

Graynomad

You can use a MUX (say the 74CBT3257) to switch the SPI lines back and forth. I built an emulator that did just that and it worked fine.

This is just a solid state version of your switch idea.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

johnwasser

Have you tried just setting the programming outputs from the UNO to inputs?  That should prevent them from interfering with the operation of the ATtiny.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

winneymj

Both are excellent ideas, I will give them a try.  Thanks for you help.

Mark

Coding Badly

Have you tried just setting the programming outputs from the UNO to inputs?


That should already be happening.  The ArduinoISP sketch keeps the SPI pins (and SS/RESET) as input / no pullup except when actively programming.

Coding Badly

Quote
My problem is that I have to disconnect the ISP programming pins from the Arduino to the ATtiny to allow I2C to work.


Once the Arduino has finished programming the ATtiny, there should be no interference.  The Arduino pins should be configured hi-Z (input / no pullup).

Are you using the ArduinoISP sketch?

winneymj

Hi Coding Badly,
I am using your new TinyISP that works with the 1.0 IDE, as you know the ArduinoISP does not work under 1.0.
So you are saying that the TinyISP sets the ISP pins to inputs after uploading the code to the ATtiny and that any connections on the ATtiny using those same pins (I2C) to a real-time clock should be able to function?


Thanks
Mark

Coding Badly

Hi Mark,

So you are saying that the TinyISP sets the ISP pins to inputs after uploading the code to the ATtiny


Yes.  RESET is released after the SPI pins are reconfigured as INPUTs.  The target can only run if the SPI pins are INPUTs.  The code of interest is in end_pmode.

After uploading, it may be possible for the internal pull-up to be enabled on SCK or MOSI but that would indicate a problem with the SPI circuitry (very unlikely).    If the SPI circuitry includes separate output drivers then that situation is impossible.  With the exception of a loose wire on RESET and a stroke of very bad luck, I cannot think of any failures that would allow the target to run with the SPI pins configured as OUTPUTs.

If you're still concerned, put a series resistor (250 ohms or more) on MOSI and SCK.  In the event of a problem, the resistors will protect all the players from damage.


Quote
and that any connections on the ATtiny using those same pins (I2C) to a real-time clock should be able to function?


You may have to isolate the RTC during programming.  I have to idea how an I2C device reacts to "random" activity on the bus.

Does the RTC have a RESET?  Or an ENABLE?  You may be able to use that to keep the RTC quiet during programming.


In any case, there should be no need to disconnect / reconnect the programmer.

Startgroup

Hello, just looking for an update. Did you get the AtTiny85 working with the RTC? Thats what I am trying to do, but I am a newbie.

mrburnette

I'm using the ATtiny85 under Arduino 1.0 without issues (at least for now!)  :D

Here is the boards and variants necessary:
http://hlt.media.mit.edu/?p=1695

I'm using Ladyada's Prototype ZIF board: http://www.adafruit.com/products/462

And I'm using Ladyada's modified Arduino code for the ISP:
https://raw.github.com/adafruit/ArduinoISP/master/ArduinoISP2.pde

- Ray

Go Up