-->
Page 1 of 2

ADC_MODE(ADC_VCC) ends up in illegal instruction

PostPosted: Wed Apr 04, 2018 1:11 am
by dynek
Hey!

I'm trying to use ADC_MODE to read voltage on an ESP-07.
I have a working sketch but as soon as I add this instruction - ADC_MODE(ADC_VCC) - at the very top of it, the ESP starts throwing exceptions:

Code: Select allException (0):
epc1=0x4022fc20 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: sys
sp: 3ffff810 end: 3fffffb0 offset: 01a0

>>>stack>>>
3ffff9b0:  00000138 00000138 00000006 00000001 
3ffff9c0:  00000138 00000000 00000002 40006784 
3ffff9d0:  00000001 3ffeea48 6f75797d 4022676b 
3ffff9e0:  00000000 402300ec 00000000 3ffeea48 
3ffff9f0:  00000006 00000001 00000004 00000000 
3ffffa00:  1d1a1812 19161310 00000000 00000000 
3ffffa10:  00003045 4022dc2c 00000000 402317d0 
3ffffa20:  00000bf0 402317e5 3ffeea48 00000001 
3ffffa30:  3ffeeb9a 3ffeea58 00000001 00000003 
3ffffa40:  3ffeea48 60000600 60000200 00000000 
3ffffa50:  4022d4d3 00000000 00000001 3ffeeb9a 
3ffffa60:  40105dbe 60000e00 07c107c1 07c10001 
3ffffa70:  402324e8 05070307 02030102 fe92130c 
3ffffa80:  00000000 b2000778 405ccf7f 05fe120f 
3ffffa90:  00000000 0000689e 3fff050c 40227d57 
3ffffaa0:  3ffee5ae 60000e00 3ffee58c 3ffee5ae 
3ffffab0:  00000001 00000001 00000000 ffff0000 
3ffffac0:  40228633 3fff050c ffffffff 402285db 
3ffffad0:  3fff04ec 00001000 40104bca 0000007d 
3ffffae0:  000000ed 00000020 3fffff10 00000000 
3ffffaf0:  3fff058c 00000000 00000003 47214850 
3ffffb00:  ffffffff ffffffff ffff0002 00000000 
3ffffb10:  00000000 00000000 00000000 00000000 
3ffffb20:  00000000 00000000 00000000 00000000 
3ffffb30:  ffffffff 00ffffff 00000000 00000000 
3ffffb40:  00000000 00000000 00000000 00000000 
3ffffb50:  00000000 00000000 00000000 00000000 
3ffffb60:  00000000 00000000 00000000 00000000 
3ffffb70:  00000000 ff000000 ffffffff ffffffff 
3ffffb80:  ffffffff ffffffff ffffffff ffffffff 
3ffffb90:  ffffffff ffffffff ffffffff ffffffff 
3ffffba0:  ffffffff ffffffff ffff00ff ffffffff 
3ffffbb0:  0000000a 5f505345 38373730 00003034 
3ffffbc0:  00000000 00000000 00000000 00000000 
3ffffbd0:  00000000 00000000 00000000 00000000 
3ffffbe0:  00000000 00000000 00000000 00000000 
3ffffbf0:  00000000 00000000 00000000 00000000 
3ffffc00:  00000000 00000000 00000000 00000000 
3ffffc10:  00000000 ffffffff ffffffff ffffffff 
3ffffc20:  ffffffff ffffffff ffffffff ffffffff 
3ffffc30:  ffffffff 000001ff ffffff04 ffffff01 
3ffffc40:  ffffffff ffffffff ffffffff ffffffff 
3ffffc50:  ffffffff ffffffff ffffffff ffffffff 
3ffffc60:  ffffffff ffffffff ffffffff ffffffff 
3ffffc70:  ffffffff ffffffff ffffffff ffffffff 
3ffffc80:  ffffffff ffffffff ffffffff ffffffff 
3ffffc90:  ffffffff ffffffff ffffffff ffffffff 
3ffffca0:  ffffffff ffffffff ffffffff ffffffff 
3ffffcb0:  ffffffff ffffffff ffffffff ffffffff 
3ffffcc0:  ffffffff ffffffff ffffffff ffffffff 
3ffffcd0:  ffffffff ffffffff ffffffff ffffffff 
3ffffce0:  ffffffff ffffffff ffffffff ffffffff 
3ffffcf0:  ffffffff ffffffff ffffffff ffffffff 
3ffffd00:  ffffffff ffffffff ffffffff ffffffff 
3ffffd10:  ffffffff ffffffff ffffffff ffffffff 
3ffffd20:  ffffffff ffffffff ffffffff ffffffff 
3ffffd30:  ffffffff ffffffff ffffffff ffffffff 
3ffffd40:  ffffffff ffffffff ffffffff ffffffff 
3ffffd50:  ffffffff ffffffff ffffffff ffffffff 
3ffffd60:  ffffffff ffffffff ffffffff ffffffff 
3ffffd70:  ffffffff ffffffff ffffffff ffffffff 
3ffffd80:  ffffffff ffffffff ffffffff ffffffff 
3ffffd90:  ffffffff ffffffff ffffffff ffffffff 
3ffffda0:  ffffffff ffffffff ffffffff ffffffff 
3ffffdb0:  ffffffff ffffffff ffffffff ffffffff 
3ffffdc0:  ffffffff ffffffff ffffffff ffffffff 
3ffffdd0:  ffffffff ffffffff ffffffff ffffffff 
3ffffde0:  ffffffff ffffffff ffffffff ffffffff 
3ffffdf0:  ffffffff ffffffff ffffffff ffffffff 
3ffffe00:  ffffffff ffffffff ffffffff ffffffff 
3ffffe10:  ffffffff ffffffff ffffffff ffffffff 
3ffffe20:  ffffffff ffffffff ffffffff ffffffff 
3ffffe30:  ffffffff ffffffff ffffffff ffffffff 
3ffffe40:  ffffffff 00000003 ffffffff ffffffff 
3ffffe50:  ffffffff ffffffff ffffffff ffffffff 
3ffffe60:  ffffffff ffffffff ffffffff ffff0064 
3ffffe70:  00000000 00000000 ffffffff ffffffff 
3ffffe80:  ffffffff ffffffff ffffffff ffffffff 
3ffffe90:  ffffffff ffffffff ffffffff ffffffff 
3ffffea0:  ffffffff ffffffff ffffffff ffffffff 
3ffffeb0:  ffffffff ffffffff ffffffff ffffffff 
3ffffec0:  ffffffff ffffffff ffffffff ffffffff 
3ffffed0:  ffffffff ffffffff ffffffff ffffffff 
3ffffee0:  ffffffff ffffffff ffffffff ffffffff 
3ffffef0:  ffffffff ffffffff ffffffff ffffffff 
3fffff00:  ffffffff ffffffff ffffffff ffffffff 
3fffff10:  ffffffff ffffffff ffffffff ffffffff 
3fffff20:  ffffffff ffffffff ffffffff ffffffff 
3fffff30:  ffffffff ffffffff ffffffff ffffffff 
3fffff40:  ffffffff ffffffff ffffffff ffffffff 
3fffff50:  ffffffff ffffffff ffffffff ffffffff 
3fffff60:  ffffffff ffffffff ffffffff ffffffff 
3fffff70:  ffffffff ffffffff ffffffff ffffffff 
3fffff80:  ffffffff ffffffff ffffffff ffffffff 
3fffff90:  cf5cffff 4078077f ffff0081 bd57ece9 
3fffffa0:  000001e9 1f9da098 ffffff01 55aa55aa 
<<<stack<<<


which translates into:

Code: Select allException 0: Illegal instruction
Decoding 14 results
0x4022fc20: tx_pwctrl_init_cal at ?? line ?
0x4022676b: pm_enable_gpio_wakeup at ?? line ?
0x402300ec: tx_pwctrl_init at ?? line ?
0x4022dc2c: txpwr_offset at ?? line ?
0x402317d0: chip_v6_initialize_bb at ?? line ?
0x402317e5: chip_v6_initialize_bb at ?? line ?
0x4022d4d3: phy_init at ?? line ?
0x40105dbe: register_phy_ops at ?? line ?
0x402324e8: register_chipv6_phy at ?? line ?
0x40227d57: uart_div_modify at ?? line ?
0x40228633: flash_data_check at ?? line ?
0x402285db: flash_data_check at ?? line ?
0x40104bca: wdt_feed at ?? line ?


Any idea? Is it supposed to work on this model?

Thank you

Re: ADC_MODE(ADC_VCC) ends up in illegal instruction

PostPosted: Wed Apr 04, 2018 8:18 am
by schufti
probably better to show your sketch ... seems to be the culprit as no one else complained about ESP-07 and ADC problems.

Re: ADC_MODE(ADC_VCC) ends up in illegal instruction

PostPosted: Wed Apr 04, 2018 12:26 pm
by dynek
Well thing is the sketch works without the extra instruction and starts throwing exceptions when added. I have just tried it with the blink example from the Arduino IDE.
The LED blinks OK but as soon as I add the ADC_MODE it stops working with illegal instructions...
Code: Select all/*
 ESP8266 Blink by Simon Peter
 Blink the blue LED on the ESP-01 module
 This example code is in the public domain
 
 The blue LED on the ESP-01 module is connected to GPIO1
 (which is also the TXD pin; so we cannot use Serial.print() at the same time)
 
 Note that this sketch uses LED_BUILTIN to find the pin with the internal LED
*/

// ADC to read VDD
ADC_MODE(ADC_VCC);

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);     // Initialize the LED_BUILTIN pin as an output
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // Turn the LED on (Note that LOW is the voltage level
                                    // but actually the LED is on; this is because
                                    // it is active low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
}

Re: ADC_MODE(ADC_VCC) ends up in illegal instruction

PostPosted: Wed Apr 04, 2018 2:25 pm
by destroyedlolo
Hi,

Are U sure about your power supply and do you put a decoupling capacitor b/w 3.3v and GND ?

I had such random crashes (not with ADC) and it came from weak power connectivity.

Bye