Changing direction of pins runtime

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JaSi_1632926
Level 4
Level 4
Welcome! 25 replies posted 10 replies posted

Hello, During factory testing (on board level - where we have several unconnected ports) we'd like to detect soldering issues on GPIOs. One neat way to do this is to iterate over all the unconnected GPIOs, set one of them to output (digital high), and read in the rest (they should all be 0). However, in order to do this we need to be able to dynamically reconfigure the port direction and drive strength. Is this possible during runtime? We need to be able to turn an input pin to an output pin, and vice versa. Thanks, Jacob

0 Likes
1 Solution

As long as you don't disable the input buffer in pin's configuration the pins will be input and output. So you can read the pins at any time. Output should be configured as "high impedance digital" when reading.

Bob

View solution in original post

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You may change the pins drive mode at any time. See pin datasheet, Pin_SetDriveMode() API and the drive mode constants.

Bob

0 Likes

Yes, but that won't change the direction, will it?

- Jacob

0 Likes

As long as you don't disable the input buffer in pin's configuration the pins will be input and output. So you can read the pins at any time. Output should be configured as "high impedance digital" when reading.

Bob

0 Likes