Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Serial] Guru meditation error when changing baudrate and using Wire #2015

Closed
toomasz opened this issue Nov 4, 2018 · 11 comments
Closed

[Serial] Guru meditation error when changing baudrate and using Wire #2015

toomasz opened this issue Nov 4, 2018 · 11 comments

Comments

@toomasz
Copy link
Contributor

toomasz commented Nov 4, 2018

Hardware:

Board: ESP32 OLED V2.0 TTGO
Core Installation/update date: 04.11.2018
IDE name: Visual Micro
Flash Frequency: 40Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 10

Description:

I'm building a library for sim800l modem which needs to find it's current baudrate.
Guru meditation error occurs when program try to iterate through baudrates for the second time.
It seems that Serial.begin hangs sometimes.

When im not initializing Wire in setup, Guru meditation error does not occur but Serial.begin is stuck anyway.

#include <Wire.h>

const int _baudRates[] =
{
	460800,
	115200,
	19200,
	38400,
	230400,
	9600,
	4800,
	57600,
	2400,
	1200,
	0
};

void setup() 
{

	Serial.begin(500000);
	Wire.begin(4, 15);
	Wire.beginTransmission(188);
	Wire.endTransmission();
}

void loop() 
{
	int i = 0;
	do
	{
		int baudRate = _baudRates[i];
		Serial.printf("trying baud rate: %d\n",baudRate);
		Serial2.end();
		Serial2.begin(baudRate, SERIAL_8N1, 16, 12, false);	
		Serial2.println("AT");
		i++;
	} 
	while (_baudRates[i] != 0);

	Serial.println("loop");
	delay(300);
}

Debug Messages:

Opening port
Port open
�trying baud rate: 460800
trying baud rate: 115200
trying baud rate: 19200
trying baud rate: 38400
trying baud rate: 230400
trying baud rate: 9600
trying baud rate: 4800
trying baud rate: 57600
trying baud rate: 2400
trying baud rate: 1200
loop
trying baud rate: 460800
Guru Meditation Error: Core  1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC      : 0x40081a07  PS      : 0x00050034  A0      : 0x40081e0c  A1      : 0x3ffbe790  
A2      : 0x3ffbec48  A3      : 0x00000000  A4      : 0x00000001  A5      : 0x400880a0  
A6      : 0x00000000  A7      : 0x3ffbe7d0  A8      : 0x3ff40000  A9      : 0x00000001  
A10     : 0x3ffbe7c8  A11     : 0x00000001  A12     : 0x00000000  A13     : 0x00000001  
A14     : 0x00000000  A15     : 0x3ffb8414  SAR     : 0x00000015  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffff  
Core 1 was running in ISR context:
EPC1    : 0x4000bff0  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x40081a07

Backtrace: 0x40081a07:0x3ffbe790 0x40081e09:0x3ffbe7c0 0x4000bfed:0x00000000

Core 0 register dump:
PC      : 0x400d543a  PS      : 0x00060134  A0      : 0x80087225  A1      : 0x3ffbbfd0  
A2      : 0x00000008  A3      : 0x00000000  A4      : 0x00000001  A5      : 0x80000020  
A6      : 0x00000000  A7      : 0x3ffbbb2c  A8      : 0x3ffc11dc  A9      : 0x3ffc11c0  
A10     : 0x00000000  A11     : 0x00000001  A12     : 0x00000000  A13     : 0x00000001  
A14     : 0x00060120  A15     : 0x00000000  SAR     : 0x00000000  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  


Decoded:
PC: 0x40081a07: _uart_isr at C:\Users\xxx\Documents\Arduino\hardware\espressif\esp32\cores\esp32\esp32-hal-uart.c line 81
EXCVADDR: 0x00000000

Decoding stack results
0x40081a07: _uart_isr at C:\Users\xxx\Documents\Arduino\hardware\espressif\esp32\cores\esp32\esp32-hal-uart.c line 81

@lbernstone
Copy link
Contributor

Have you tried using #1961? He includes a timeout which should keep from triggering the watchdog.

@stickbreaker
Copy link
Contributor

Put a flush after your println. Changing baud in the middle of sending is bad.

@toomasz
Copy link
Contributor Author

toomasz commented Nov 5, 2018

@stickbreaker Tried, it doesn't help.
@lbernstone Gsm module doesn't send data without me prompting for it so its different scenario

@NickChungVietNam
Copy link

NickChungVietNam commented Nov 18, 2018

		Serial.printf("trying baud rate: %d\n",baudRate);
                delay(20);//ADD DELAY
		Serial2.end();   
               delay(20);//ADD DELAY
		Serial2.begin(baudRate, SERIAL_8N1, 16, 12, false);
               delay(20);	//ADD DELAY
		Serial2.println("AT");
		i++;

@toomasz
Copy link
Contributor Author

toomasz commented Nov 22, 2018

@NickChungVietNam Tried it, makes baud rate negotiation more stable when 460800 rate is excluded from list.
With 460800 still getting said exception.

@NickChungVietNam
Copy link

NickChungVietNam commented Nov 23, 2018

@NickChungVietNam Tried it, makes baud rate negotiation more stable when 460800 rate is excluded from list.
With 460800 still getting said exception.

You need define type 460800 in "usigned long" or (uint32_t). To check the current baudrate value , use Serial.printf("Serial2 = %d \n" , Serial2.baudRate() );

@toomasz
Copy link
Contributor Author

toomasz commented Nov 23, 2018

I don't think unsigned long or int makes a difference in that case. int max value on esp32 is 2147483647

@NickChungVietNam
Copy link

NickChungVietNam commented Nov 23, 2018

See this ::begin
Did you try like this ?Serial2.begin(460800 );

@toomasz
Copy link
Contributor Author

toomasz commented Nov 23, 2018

I updated arduino-esp32 to latest commit as I saw some serial related code was merged recently.
Seems to work without crash when small delay is added after Serial.end() !

see:
https://github.com/toomasz/SimcomGsmLib/blob/9ac948ab1aa8d33b3af3ca1b4fac4d0889095cad/src/SimcomGsmLibEsp32.h#L13-L24

@toomasz
Copy link
Contributor Author

toomasz commented Dec 20, 2018

Im still experiencing problem. I narrowed it down to uartEnableInterrupt call from uartAttachRx. Seems uartEnableInterrupt is getting deadlock for some reason

@toomasz
Copy link
Contributor Author

toomasz commented Dec 23, 2018

Closing as I don't need to do trick with Serial.begin/end. Im using changeBaudRate introduced in #2223

@toomasz toomasz closed this as completed Dec 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants