Electronic – arduino – ATMEGA328P: Can I re-use PB4(MISO) w/ a pull-up resistor w/o interfering w/ SPI

1-wirearduinospi

I have a Freetronics Eleven with their Ethernet Shield and I would like to add a DS2502-E48 to the circuit to provide the hardware MAC address. This nifty little gem from Maxim uses the Dallas 1-wire bus, and if possible I would like to reuse one of the pins already tied up on the Arduino/Shield rather than reducing the pins available for prototypes.

The SPI pins (11, 12, 13) are already claimed by the shield, but I only need to talk to the DS2502-E48 for a few ms during initialization, so I am wondering if I could use pin 12 (MISO) briefly as the 1-wire data line. With no CS line active for any SPI device, they'll be ignoring the bus, so there shouldn't be any interference there. But the 1-wire spec calls for a pull-up resistor connected to +5V… Would that interfere with SPI activity later?

Alternatively could I get away without the pull-up resistor in this case? I am vague on all theory, but it seems like the pull-up is there so that parasite devices get power. If I use the internal pull-up to power the pin for a few ms, then talk to the DS2502-E48 long enough to get the data I need, can I just let the line revert to it's normal SPI function afterwards?

Note that I don't currently have plans for more 1-wire devices… If I need 1-wire for a prototype I would dedicate a different pin.

Best Answer

It would be extremely easy to provide a pullup that was active only during initialisation and that "vanished" completely thereafter.

  • Active: PNP transistor is turned on by a capacitor at powerup and pulls pullup high. Cap is charged and transistor trns off after 1 to 2 time constants.

  • Passive: Capacitor provide V+for pullup resistor via a diode. Cap charges (or effectively discharges depending on perspective) with a separate resistor and pullup drive disappears aftr 1 time constant or so. Diode makes cap "invisible" when "charged".


(1) An "active pullup" would be easier to "design" properly than a passive and could consist of a capacitor and a "digital" transistor (ie internal base resistors). So could be very small - two components plus actual pullup resistor. Adding another r or 2 may help get timing more predictable but 1R version should be OK.

  • Digital PNP with internal R from base to emitter and internal R from base to base input pin.

  • Capacitor base pin to ground.

  • Collector to pullup.

On turn on Vcap = 0 so base input pin is at 0 so transistor is on.
Cap charges via internal base resistor.
When Cap reaches ~= V+ -0.5 transistor turns off.

Size /cost / values: See (2) below for capacitor sizing and cost, but note that a much smaller capacitor value may be used by choosing a much larger base resistor value to charge the capacitor than can be used with the passive design. eg a 10k base resistor would allow about a 1 uF cap and something as extreme as this ROHM PNP with 100k input resistor datasheet here would allow probably a 0.01 - 0.05 uF range cap. Available in 4 pkgs from SOT23 down to VMT3 1.2mm x 0.8mm !!! :-) for the terminally enthused. ).047 uF X5R cap can be 0201 (if desired) for equal amusement at under 1 cent

Transistor cost dominates here in this case at about 10 cents !!! but much much cheaper will be available.

(2) A passive pullup is probably larger and more costly as installation cost will predominate in volume manufacture. But:

This could "safely" be as little as

  • C1 = 1 x cap (C+ = V+),

  • R1 = 1 x resistor (C- to ground),

  • D1 = 1 x diode (junction of R&C to pullup), +

  • R2 = pullup to wherever.

C1 starts with 0 charge so when V+ rises C+ is pulled to V+ and C- also. Cap now discharges via R1 so C-falls from V+ to ground. D1 isolates cap from pullup once cap is discharged. Pullup provides whatever value is required for bus. I2 R2 = pullup is say 5 to 10+ times as large as R1 then R1 will dominate discharge time.

Size /cost / values: If you need "a few mS" say time constant = 10 mS. Maxim say pulup should be about 4k7.
This is shown the same for parasitic powering and when Vdd is available so I strongly suspect that a larger value is acceptable when Vdd is provided BUT lets stick wityh 4k7. (Other issues is time constant od R oullup +_ parasitic capacitance on 1 wire bus).

Make R1 = 1k.
Time constant = 10 mS
so C1 = 10 uF = not nice, but bearable.

eg this TDK 0805 pkg, 10uF, 10V, Y5V material, costs 2.5 cents at 2000 volume and under 2 cents above 10k volume at Digikey. Probably half or less from China. Y5V may be a bit "exciting at say +20%/-80% across temperature (-55/+85) and still not marvellous at say 0-55C.

Rather better X5R (+/- 20% across temperature) is also ins ame size pkg (0805 x 1.5mm tall) at about +50% price premium (Digikey 2.8C/26k)

Given the horrific price of the 1 wire IC you may not mind the few cents for the cap.

(3) PIC10F or similar drives pullup :-)

Or then there's this which I think may be a one off offer, or a mistake or last years April fools day joke or ... . 33 cents/10 k for microcontroller with 5 x 10 bit ADC, Brownout, power on reset, IIC, IRDA, SPI, UART, PWM, internal osc, watchdog, 8kB flash, 128 byte eprom, ... !!!!!!!!!!!!! datasheet.
What a pullup controller that would make :-).