-->
Page 1 of 1

UART pins as GPIO

PostPosted: Thu Mar 05, 2015 10:18 am
by dmarkey
I need 3 GPIO pins to drive a shift register, however I cant seem to get GPIO1/3 (UART) to act as ordinary output pins.

Would this the code i'm using:

Code: Select all    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U,FUNC_GPIO1);
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U,FUNC_GPIO3);
   
    while ( true){
        GPIO_OUTPUT_SET(2, 1);
        GPIO_OUTPUT_SET(1, 1);
        GPIO_OUTPUT_SET(3, 1);
        GPIO_OUTPUT_SET(0, 1);
        os_delay_us(1000000);
        GPIO_OUTPUT_SET(2, 0);
        GPIO_OUTPUT_SET(1, 0);
        GPIO_OUTPUT_SET(3, 0);
        GPIO_OUTPUT_SET(0, 0);
        os_delay_us(1000000);
       
       
    }


this anywhere near the mark?

Re: UART pins as GPIO

PostPosted: Thu Mar 05, 2015 11:27 am
by MK1888
This thread might help: http://www.esp8266.com/viewtopic.php?f=13&t=273

But also, you can drive a shift register with only one pin, if you want: http://www.romanblack.com/shift1.htm

Re: UART pins as GPIO

PostPosted: Thu Mar 05, 2015 11:38 am
by EadF
The mux that correlates to FUNC_GPIO3 is called PERIPHS_IO_MUX_U0RXD_U and FUNC_GPIO1 -> PERIPHS_IO_MUX_U0TXD_U. (eagle_soc.h)

And you will have to make sure that you didn't activate UART0.

Here is a small, alternative uart implementation, one that frees up the RX pin for GPIO use, but still allows you to do os_printf() to the console. https://github.com/eadf/esp8266_stdout (made by Jeroen Domburg)