-->
Page 1 of 1

GPIO12-GPIO15 unresponsive, JTAG override?? [SOLVED]

PostPosted: Sun Oct 11, 2015 11:43 pm
by jesper
I have a ESP-12E board (ESP12-Q) and wanted to use GPIO12-15 for various stuff.
GPIO15 is pulled to GND through a 1k resistor to allow proper startup. Programming all works fine, as does I/O on GPIO0-GPIO5 and GPIO16.

However, GPIO12 to GPIO15 is not working properly. I've set them all to outputs, toggling at 1 Hz together with GPIO0-GPIO5,GPIO16.
They're not doing anything at all, GPIO12, 13 and 14 are high and GPIO15 is low (most likely due to the extern pulldown).
The odd thing is, that just measuring on GPIO13 or giving it a slight negative pulse, will cause GPIO15 to go (and stay) high.
Now, that these pins also double as JTAG pins, GPIO13 is MTCK and GPIO15 is MTDO, this looks suspiciously like the JTAG interface is enabled and a stray clock caused MTDO to go high.

I've looked high and low, but see no way of how to disable the JTAG pins. I'm using the "regular" pin config to set the pins to GPIO:
Code: Select all   
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12);
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13);
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14);
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15);

But to no avail.

I see many code examples where these GPIO pins are used for both input and output, so what the h*** is wrong here??
Am I missing something?

I've tried my code on a ESP-07 too, same problem, JTAG seems to take over.

I'm running with SDK 1.3.0


Tips and hints much appreciated.

/J

Edit:

Problem solved, it turned out I had an incorrect PIN_FUNC_SELECT macro. Worked when setting GPIO pins that were at function 1, but not at function 3.

Re: GPIO12-GPIO15 unresponsive, JTAG override??

PostPosted: Mon Oct 12, 2015 5:01 am
by jesper
This has be stumped :x

Here's my test code, would be nice if anyone could test and let me know the result. If it DOES work for you, with GPIO15, I'd love to get a copy of your binary to test run on my board.

Code: Select all/*
 * Minimal GPIO toggle test.
 */

#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"



// does not work
//#define PIN_MUX      PERIPHS_IO_MUX_MTDO_U
//#define PIN_FUNC   FUNC_GPIO15
//#define PIN_BIT      BIT15

// works
#define PIN_MUX      PERIPHS_IO_MUX_GPIO2_U
#define PIN_FUNC   FUNC_GPIO2
#define   PIN_BIT      BIT2


#define user_procTaskPrio        0
#define user_procTaskQueueLen    1
os_event_t    user_procTaskQueue[user_procTaskQueueLen];
static void user_procTask(os_event_t *events);

static volatile os_timer_t some_timer;

void some_timerfunc(void *arg)
{
    static int toggle = 0;

    if (++toggle & 1)
        gpio_output_set(0, PIN_BIT, PIN_BIT, 0);
    else
        gpio_output_set(PIN_BIT, 0, PIN_BIT, 0);
}

//Do nothing function
static void ICACHE_FLASH_ATTR
user_procTask(os_event_t *events)
{
    os_delay_us(10);
}

void user_rf_pre_init() {
   //Not needed, but some SDK versions want this defined.
}

//Init function
void ICACHE_FLASH_ATTR
user_init()
{
    // Initialize the GPIO subsystem.
    gpio_init();

    //Set GPIO to output mode
    PIN_FUNC_SELECT(PIN_MUX, PIN_FUNC);

    // Setup timer and run
    os_timer_disarm(&some_timer);
    os_timer_setfn(&some_timer, (os_timer_func_t *)some_timerfunc, NULL);
    os_timer_arm(&some_timer, 500, 1);
    system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
}