PDA

View Full Version : Output directly to input?



Michael
- 29th January 2020, 22:38
I've never done it before, so it pays to ask. If I configure 2 pins on a pic, one to output the other to input, can they be connected directly to each other? Maybe standard practice would be to use a resistor or maybe a diode between?
-- thanks

Jerson
- 30th January 2020, 04:06
Yes, you can. Output pins are the ones to create trouble when connected together.

peterdeco1
- 30th January 2020, 10:10
Yes. A while back I tied the HPWM output to an input and programmed it to make all my output ports go high and low with the input. I had multiple outputs at the same frequency as the HPWM.

towlerg
- 30th January 2020, 11:37
@Peter I was just about to ask why do that and you answered.

@Micheal If pins are on the same Port, write to the whole TRIS in one go ie. don't set up individual pins as output/input. BTW pins default to input.

Ioannis
- 30th January 2020, 12:46
Doing it fast, won't have issues with R-M-W ?

Ioannis

mpgmike
- 30th January 2020, 13:46
The only advantage I can see is if you have a pin-specific function that requires a hardware input, and cannot be connected with software -- perhaps a Comparator. The newer PIC offerings more and more allow inputs to special functions to be tied to outputs of other functions through software gating/muxing.

What are you ACTUALLY trying to accomplish? Would you be open to using a different PIC if it made more sense?

Michael
- 30th January 2020, 14:51
I have a tactile switch going low on an input but thought I'd add a remote control. So I'll sense the infrared remote on another input pin, just looking for any button press, if that pin goes low (with a pull up attached) (any button press will make the receiver go low) then I'll have a normally high output pin go low for a few secs and this output will be connected to the switch input pin. Breadboarded it and it works fine. Did use a 1K between the pins.

Bought one of these real cheap HX1838 remotes off ebay (<2 bucks).

Has anyone had experience with these? Seems to me years ago when I built an infrared pair with a module, it was problematic but this is working great. Wondering if it may have any sunlight issues and false triggering on the receiver. so far, no problem.

peterdeco1
- 30th January 2020, 16:22
Yes Ioannis I would expect it would have issues at high speed. It was an experiment at low speed just to see if a PIC could "mirror" an output on multiple pins.