Hello there,
I am using a Pic18 for my project. One pin needs to be switched between input and output mode during operation. How do i realise that?
Switch gpio between input and output
Moderator: Benj
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Switch gpio between input and output
In most cases you can simply mix use of both the "Input" icon and the "Output" icon on the Flowchart, the code generated will swap the I/O direction for you.
-
- Posts: 24
- Joined: Wed Apr 29, 2015 4:49 pm
- Has thanked: 5 times
- Been thanked: 5 times
- Contact:
Re: Switch gpio between input and output
Thank you, for your fast reply. What will happen, if ill set an output to high state and then use it as an input and ask for its status. Will the pin stay high?
Regards
Regards
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Switch gpio between input and output
That depends upon what you have connected to it.
I think you need to explain in a bit more detail what you are trying to do, and what electronic components you have attached to this I/O pin, e.g. a circuit diagram
I think you need to explain in a bit more detail what you are trying to do, and what electronic components you have attached to this I/O pin, e.g. a circuit diagram
-
- Posts: 24
- Joined: Wed Apr 29, 2015 4:49 pm
- Has thanked: 5 times
- Been thanked: 5 times
- Contact:
Re: Switch gpio between input and output
Ok. The pin is conected to a display/touch module. During startup the state of the connected pin on the the display has to be active low. After startup procedure the display module signals on that same pin with a active low state, if there has been a touch action. So my question is: if i put that pin of the mc in a certain state, then later use it as an input and ask for its state, will i get the status of the connected display or the status i put in the pin before when it was still an output.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: Switch gpio between input and output
It sounds like the module has an open collector/drain type I/O then, if so, if you use an input macro you will get the status of the connected display