cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Smart Bluetooth

Contributor II

I am using a GPIO pin to control an LED, active low.

It occurred to me that it might be possible to set the GPIO to high impedance (input and output disabled) when the LED is not in use.

However, it seems like only the first call to gpio_configurePin() has an effect.  Is there any way to change the configuration of a pin after configuring it once?

0 Likes
Reply
1 Solution
Contributor II

OK, I got it to work, but it’s a little strange. I found that the port 0 pins behave strangely (I have 3 port 0 pins that I want to drive this way).

For any port 0 pin, I found that I need to FIRST initialize it to output high. After setting it output high, I’m able to switch it back and forth to hi-z and output low. Note, my code is also using 0x100 instead of INPUT_DISABLE.

For the port 1 pin, it works without the first step.

My original code initialized it by setting it high-Z directly, but this apparently gets it into a state where it won’t subsequently drive low.

Thanks for the tips!

View solution in original post

0 Likes
Reply
5 Replies
Employee

Yes, it is possible to reconfigure any pin at any time. How are you driving the GPIO? I would do it this way:

// Drive the GPIO LOW.

gpio_configurePin(PORT, PIN, GPIO_OUTPUT_ENABLE, GPIO_OUTPUT_LOW);

// Input and output disable GPIO (when PORT != 0 and PIN !=0). The last parameter is a don't care when output is not enabled.

gpio_configurePin(PORT, PIN, GPIO_INPUT_DISABLE, GPIO_OUTPUT_LOW);

// When PORT == 0 and PIN == 0 use this instead.

gpio_configurePin(PORT, PIN, 0x100, GPIO_OUTPUT_LOW);

0 Likes
Reply
Contributor II

Hi Arvind,

So, oddly, this works OK for port 1 pin 11, but not for port 0, pin 14. I tried substituting 0x100 for INPUT_DISABLE, but this did not work.

I realize that 0,14 is the tag’s LED, but I removed the LED entries from the BLE_PROFILE_GPIO_CFG structure, so I don’t think that should be interfering.

0,14 works OK if I drive it high / low.

Any thoughts?

0 Likes
Reply
Employee

And are you trying to do this on the tag or on your own board?

0 Likes
Reply
Contributor II

it is my own board, but the design is quite similar. That port connects to an LED in the same way as the tag.

0 Likes
Reply
Contributor II

OK, I got it to work, but it’s a little strange. I found that the port 0 pins behave strangely (I have 3 port 0 pins that I want to drive this way).

For any port 0 pin, I found that I need to FIRST initialize it to output high. After setting it output high, I’m able to switch it back and forth to hi-z and output low. Note, my code is also using 0x100 instead of INPUT_DISABLE.

For the port 1 pin, it works without the first step.

My original code initialized it by setting it high-Z directly, but this apparently gets it into a state where it won’t subsequently drive low.

Thanks for the tips!

View solution in original post

0 Likes
Reply