weird problem with gpio_config

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

weird problem with gpio_config

Postby mzimmers » Mon Jul 23, 2018 10:06 pm

Here's the code fragment:

Code: Select all

void PowerMgr::powerMgr_task(TaskParams *params)
{
    LedQueueEntry lqe;
    TickType_t delay;
    gpio_config_t gpioConfig;
    esp_adc_cal_characteristics_t adcCharBattery; // ADC characterization (see docs)
    Message msg(params);
    esp_err_t err;
    string s;
    stringstream ss;

    m_params = params;

    s = msg.encodeXml();
    xQueueSendToBack(m_params->worker->getQueueMsgOut(), &s, 0);

    // get the queue for worker notifications.
    m_workerPowerQueue = m_params->worker->getQueuePowerChange();

    // configure the characteristics structure.
    esp_adc_cal_characterize(ADC_UNIT_1, BATTERY_A2D_ATTEN, BATTERY_A2D_WIDTH, 1100, &adcCharBattery);

    // configure the battery enable pin.
    gpioConfig.pin_bit_mask = BATTERY_EN_PIN;
    gpioConfig.mode = GPIO_MODE_OUTPUT;
    gpioConfig.pull_up_en = GPIO_PULLUP_DISABLE;
    gpioConfig.pull_down_en = GPIO_PULLDOWN_DISABLE;
    gpioConfig.intr_type = GPIO_INTR_DISABLE;

    err = gpio_config(&gpioConfig); // this is line 61 (where the exception takes place).
and here's the output:
Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception)
Debug exception reason: Stack canary watchpoint triggered (powerMgr_event_)
Core 0 register dump:
PC : 0x4008cc77 PS : 0x00060936 A0 : 0x8008cde4 A1 : 0x3ffd1f40
0x4008cc77: xQueueGenericReceive at C:/esp-idf-release-v3.0/components/freertos/queue.c:2037

A2 : 0x3ffc1ab0 A3 : 0x00000000 A4 : 0xffffffff A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000001 A8 : 0x8008b441 A9 : 0x3ffd1f50
A10 : 0x00000003 A11 : 0x00060923 A12 : 0x00060920 A13 : 0x0000006b
A14 : 0x00200000 A15 : 0x00000000 SAR : 0x00000004 EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffe

Backtrace: 0x4008cc77:0x3ffd1f40 0x4008cde1:0x3ffd1f80 0x40083611:0x3ffd1fa0 0x400836f9:0x3ffd1fd0 0x400f11a1:0x3ffd1ff0 0x400f0cc1:0x3ffd20
10 0x4000bd83:0x3ffd2030 0x4000117d:0x3ffd2050 0x400592fe:0x3ffd2070 0x4005937a:0x3ffd2090 0x40058bbf:0x3ffd20b0 0x400e1145:0x3ffd20e0 0x400
e6916:0x3ffd2110 0x400e6a59:0x3ffd2420 0x400834f6:0x3ffd2450 0x4010e329:0x3ffd24a0 0x400d5911:0x3ffd24f0 0x400d5e53:0x3ffd26b0
0x4008cc77: xQueueGenericReceive at C:/esp-idf-release-v3.0/components/freertos/queue.c:2037

0x4008cde1: xQueueTakeMutexRecursive at C:/esp-idf-release-v3.0/components/freertos/queue.c:2037

0x40083611: lock_acquire_generic at C:/esp-idf-release-v3.0/components/newlib/locks.c:155

0x400836f9: _lock_acquire_recursive at C:/esp-idf-release-v3.0/components/newlib/locks.c:169

0x400f11a1: uart_write at C:/esp-idf-release-v3.0/components/vfs/vfs_uart.c:124

0x400f0cc1: esp_vfs_write at C:/esp-idf-release-v3.0/components/vfs/vfs.c:274 (discriminator 4)

0x400e1145: __sprint_r at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/
libc/stdio/vfprintf.c:437

0x400e6916: _vfprintf_r at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib
/libc/stdio/vfprintf.c:1782 (discriminator 1)

0x400e6a59: vprintf at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdio/../../../.././newlib/lib
c/stdio/vprintf.c:39

0x400834f6: esp_log_write at C:/esp-idf-release-v3.0/components/log/log.c:215

0x4010e329: gpio_config at C:/esp-idf-release-v3.0/components/driver/gpio.c:428

0x400d5911: PowerMgr::powerMgr_task(TaskParams*) at C:/esp32_projects/wifibutton/main/powermgr.cpp:61
I should point out that this entire routine has given me odd behavior, which seems to have to do with the use of the ESP_LOGI() call, believe it or not. But they've been removed from the code, and I'm now consistently getting this problem.

Any ideas what I'm doing wrong? Thanks...

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: weird problem with gpio_config

Postby WiFive » Mon Jul 23, 2018 11:27 pm

ESP_LOGI and Stack canary watchpoint triggered suggests to make your stack larger

Who is online

Users browsing this forum: ulaoulao and 101 guests