Hi,
The READTEMP command and I2C both flip the pin from output to input and back ... so it's not "At the same time"
IMHO, the "wired OR" use of a pin, e.g. as used by READTEMP, the I2C Bus and particularly as an Interrupt Request line is a genuine, instantaneous bidirectional use of a pin. At any instant, both the PIC(axe) and the External Circuit can Read the pin status and either could request control of a/the Bus (unless it has already been claimed). The common "Open Collector/Drain" configuration with a pullup resistor, actually uses Negative Logic, i.e. the OR pin is Idle High and Active Low (often named as /INT, etc.).
Then, some Protocol may be required, for example to identify which of multiple Interrupt sources or DS18B20 sensors is to be interrogated. The READTEMP command doesn't actually support multiple sensors on a single pin, but a PICaxe can read them via its
OWIN and OWOUT commands (X2s only).
I'll give ya the weak pull-up trick ... that puts a high-signal on an input pin ... but that's a limited use-case for sure .... how do you drive that same pin low? The best you can do is kill the pull-up and let it float.
The base of a bipolar transistor can be connected directly to an "Input Only" pin and activated by enabling/disabling the relevant Weak Pullup resistor. Or for CMOS devices an external "even weaker PullDown" resistor (say 100k+) can be used, which is literally all that is required for example to control the Chip Enable or similar of another logic device or sensor, etc., from an Input Only pin (of which the 08M2 effectively has 2 of its 6 signal pins).
If you're Bit Banging a Wired-Or protocol on a bidirectional pin, you can just switch between LOW and INPUT <pin> (i.e. Tri-State) commands, but it's also possible to write one or more bits directly to the appropriate register/variable, i.e.
pinsC or
dirsC (Data Direction), etc., for example
pinsC = outpinsC xor 4 should toggle pin C.2 .
------------
The OP didn't indicate the purpose of his COUNT command, but it might be possible to reliably use it to measure a High Frequency, or the inverse PULSIN command (to measure the period of a lower, constant frequency) without any interference with the Servo command: A single servo pulse has a maximum duration of around 2.5ms, with a gap of 17.5ms to the next, so there is a "Window" of at least 15 ms where a COUNT or PULSIN could be executed. That may be sufficient to read a full byte value, and if necessary SERVOPOS can be used with a SETFREQ M16.
The are various ways that the Program code could be synchronised between the servo pulses, but as mentioned above, attempting to read the Servo Pulse from the pin itself could be problematic. Normally, I would write the program around a
PEEKSFR Timer1, ... (SFR Addresses $17 : $16) which triggers the Servo Pulses whilst counting up from 45536 to 65535 (i.e. for 20 ms). But Timer 1 is also the first prescaler (divider) for the "time" Variable, so for a modest throughput of COUNT or PULSIN you could try (untested):
Code:
do
lasttime = time
do : loop until time <> lasttime ; Wait for time to increment
pause 200 ; Wait around 2 ms, depending on maximum width of Servo Pulse(s), etc.
count C.1,10,value ; Count for 10ms
sertxd(cr,lf,#value)
; etc.
loop
Cheers, Alan.