8 years, 8 months ago.

Can I use an unused SPI pin (MISO) for GPIO?

Is it possible or is the pin unavailable once the SPI peripheral is selected? I've run out of other GPIO pins.

By the way I am using the lpc1768 mbed

Question relating to:

1 Answer

8 years, 8 months ago.

If you aren't using that pin for SPI, sure you can use it for GPIO.

Accepted Answer

I had this same question. So what would the declaration/configuration code look like for using SPI0 as output only(writes only?) and utilizing the MISO pin as a digital GPIO? I'm also using an LPC1768 MBED module.

Thanks in advance for any assistance!

posted by Douglas S 06 Sep 2015

You can use 'NC' to set a pin as non-connected. This doesn't work on all peripherals: I2C without clock makes no sense. SPI without MISO, or UART without RX, makes perfect sense, so thats supported.

For your question:

SPI spi(<mosi_pin>, NC, <sclk_pin>);
DigitalInOut dinout(<the_old_miso_pin>);
posted by Erik - 07 Sep 2015