Serial monitor hangs as well as entire IDE soon after starting

Windows XP,Vista,7,8 and 8.1 etc
stevestrong
Posts: 1749
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Serial monitor hangs as well as entire IDE soon after starting

Post by stevestrong » Tue Sep 13, 2016 8:50 am

I suspect the Ethernet lib. What kind of Ethernet controller is used? ENC28 or other type?

Phono
Posts: 91
Joined: Tue May 05, 2015 6:08 am
Location: Ermont, France

Re: Serial monitor hangs as well as entire IDE soon after starting

Post by Phono » Tue Sep 13, 2016 9:02 pm

I am using a Olimex STM32 maple-like board.
I am connecting on Serial, that is, the built-in USB-serial channel.
I have added a W5200 shield from SEEED.
The suspicion on the Ethernet.begin() statement was right. If I move it elsewhere, the problem disappears.
I am currently testing the Ethernet library that I have modified to be FreeRTOS-aware. Unfortunately it worked pretty well some time ago, but now I am stuck with a regression I cannot find so far.
I will let you know when I succeed, for I will provide you with this library for possible inclusion in the STM32 package.
Thanks for your help, often asking the wrong questions bring the right answers.

Phono
Posts: 91
Joined: Tue May 05, 2015 6:08 am
Location: Ermont, France

Re: Serial monitor hangs as well as entire IDE soon after starting

Post by Phono » Fri Sep 16, 2016 7:05 am

I have now solved the problem. However, I do not know what was wrong and why it is better now.
The problem came from two initialisations :
- the ethernet.begin()
- the TwoWire::begin().
In both cases, putting these statements in the Setup() function, before the tasks are created and the scheduler launched, lead to trouble.
I have put them at the beginning of two different tasks, before the while(true) statement, and no problem now.
As far as the ethernet library, this could make sense, since I modified it so that delay() is replaced by vTaskDelay() when used in a multitasking environment, though I carefully checked that begin() does not call delay().
For TwoWire::begin() I am at my wit's end, since this function does very little :

void TwoWire::begin(uint8 self_addr) {
tx_buf_idx = 0;
tx_buf_overflow = false;
rx_buf_idx = 0;
rx_buf_len = 0;
pinMode(this->scl_pin, OUTPUT_OPEN_DRAIN);
pinMode(this->sda_pin, OUTPUT_OPEN_DRAIN);
set_scl(HIGH);
set_sda(HIGH);
}

Of course, the wire object had been correctly defined :
TwoWire MaitreI2C(I2C_SCL, I2C_SDA) ;
I tried to insert into the Setup() the last four statements directly, and no problem arose:

pinMode(I2C_SCL, OUTPUT_OPEN_DRAIN);
pinMode(I2C_SDA, OUTPUT_OPEN_DRAIN);
TwoWire.set_scl(HIGH);
TwoWire.set_sda(HIGH);

The effect of putting the MaitreI2C.begin() in the Setup() was that one of my two tasks that handle the ethernet shield would not communicate any more.
Specifically, one task connects to an external TCP server, and the other task is a Webserver. This was the Web server that would not respond to connection attempts from my browser, though the task that handles it still ran.

I am glad it works now, but still nervous as to what was the problem, and how to manage so that it does not show again later?

Post Reply