0
\$\begingroup\$

I have one port on my MCU and want to re-define its functionality.
Is it possible that something wrong/strange happens if I do it in my main() function?
I regularly switch the funtion of the pin in millisec jobs (eg. between I2C and UART)

I appreciate your help :)

\$\endgroup\$

closed as unclear what you're asking by Scott Seidman, TonyM, Oleg Mazurov, Umar, RoyC Sep 1 at 13:57

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ Welcome to the site. Please realise this is not a free design house, homework-answering service or an on-line technical encyclopedia, copied out to you on demand. People will help you take the next step if your question shows you've done as much as you possibly could on your own - which yours doesn't, I'm afraid. Please edit your question and greatly improve it. Show your work and findings so far in considerable detail with a schematic. The schematic tool here is easy. The better the quality of question, the better the quality of the answers you will attract. Again, a warm welcome to the site. \$\endgroup\$ – TonyM Aug 28 at 9:49
  • \$\begingroup\$ @TonyM hmm not sure about your comment, but asking if changing purpos of a pin every ms have a strange results... I don't see this like a homework question or something that I would find on google. Thank you. \$\endgroup\$ – Ram Aug 28 at 12:44
  • 3
    \$\begingroup\$ This is way too vague to answer in the abstract. Feel free to provide enough details to turn it into an answerable question. \$\endgroup\$ – Scott Seidman Aug 28 at 12:54
  • 1
    \$\begingroup\$ A starting point might be a part number and link to a spec. The answer is probably different for different manufacturers and cores. \$\endgroup\$ – Cristobol Polychronopolis Aug 28 at 13:03
  • 1
    \$\begingroup\$ please tell more about external connections. Will there be some transmitter on the other side of UART? show us the schemtics. Let us know, why you want to do it too \$\endgroup\$ – Umar Aug 28 at 13:59
0
\$\begingroup\$

In general, it is likely that something unexpected will happen. In your example, both I2C and a UART use the voltages on a pin to convey serial data. The pattern of 1s and 0s for a I2C transmission might look like a valid UART transmission, depending on the I2C and UART data rates.

There are certain situations where you can get away with using one pin for multiple functions, but these require very careful design.

\$\endgroup\$
  • \$\begingroup\$ THank you :) well uart/i2c was more like an example. what I am trying to do is use I2C1 at one moment at ping eg. 1,2 and after lets say 10ms disable it and enable I2C1 that is on pin eg. 5,6. (1,2 and 5,6 are I2C1 pins). I am trying to make my MCU as bridge between 2 different I2C lines, so they do not see each other. \$\endgroup\$ – Ram Aug 28 at 14:39
  • \$\begingroup\$ Yes, that should work. Just make sure to put the not-in-use pins in a benign state...don't allow a false clock pulse to occur. \$\endgroup\$ – Elliot Alderson Aug 28 at 14:43
  • \$\begingroup\$ Perfect thank you :) \$\endgroup\$ – Ram Aug 28 at 14:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.