Serial monitor hangs as well as entire IDE soon after starting

Windows XP,Vista,7,8 and 8.1 etc
Phono
Posts: 91
Joined: Tue May 05, 2015 6:08 am
Location: Ermont, France

Serial monitor hangs as well as entire IDE soon after starting

Post by Phono » Mon Sep 12, 2016 7:44 pm

Hi,
The Arduino 1.6.9 IDE is installed on windows 10.
I have inserted in a sketch a few serial.print statements to monitor the progress of the processing in the setup function.
here is an excerpt of the code :

#define SERIAL Serial

void setup() {

// pin mode and such....

#ifdef SERIAL
SERIAL.begin(115200);
delay(2000);
SERIAL.println("Impression debug activee") ;
#else
CANSetup() ;
#endif

Ethernet.begin(mac,ip);
#ifdef SERIAL
SERIAL.println("Initialisation Client Ethernet") ;
#endif

// Initialisation de l'I2C
MaitreI2C.begin() ;
#ifdef SERIAL
delay(100);
SERIAL.print("Initialisation I2C ") ;
if ( MPU6050_Init() ) // Initialisation du gyroscope
SERIAL.println("reussie") ;
else
SERIAL.println("echouee") ;
#else
MPU6050_Init() ; // Initialisation du gyroscope
#endif

// etc.
}

When the sketch starts, only the first two prints show on the monitor window, then the IDE hangs. If I try to close the monitor window, it does not and the IDE does not respond any more, until I press the Reset button on the Olimexion STM32 board.

Any idea?

This does not occur if I use a physical serial port on the Olimexino board.

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

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

Post by martinayotte » Mon Sep 12, 2016 8:05 pm

Do you mean that the first Serial prints before the I2C.begin() are working but not the one after ?
Your MaitreI2C is probably not working and hanging. Is it a nick name for the STM32 Wire library ?
Do you have PullUps on your I2C bus ?

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 » Mon Sep 12, 2016 9:09 pm

Actually I am attempting to use the hardwire library, with :

#include <HardWire.h>

// .........

HardWire MaitreI2C ( 1, I2C_FAST_MODE ) ;

but so far with no success.

I understand what you suggest : the I2C initialisation would cause the system hang. To check for this, I have changed the code :

SERIAL.println("Initialisation I2C ") ;
delay(1000);
MaitreI2C.begin() ;
if ( MPU6050_Init() ) // Initialisation du gyroscope
SERIAL.println("reussie") ;
else
SERIAL.println("echouee") ;

So whatever the result of the initialisation of the I2C, the first print would normally work. But it does not.

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 » Mon Sep 12, 2016 9:14 pm

In addition, if I change the code above like this :

#ifdef SERIAL
SERIAL.begin(9600);
delay(2000);
SERIAL.println("Impression debug activee") ;
#else
CANSetup() ;
#endif

Ethernet.begin(mac,ip);
#ifdef SERIAL
SERIAL.print("Initialisation Client Ethernet, ") ;
SERIAL.print("Initialisation Client Ethernet 2, ") ;
SERIAL.println("Initialisation Client Ethernet 3") ;
#endif


only the first println and the first print show on the serial monitor, and it hangs after the comma :

Impression debug activee
Initialisation Client Ethernet,

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

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

Post by martinayotte » Mon Sep 12, 2016 9:24 pm

I could barely believe it ...
Several consecutive Serial.print() and it hangs after the second ?
I've never seen that ...
Your installation is kind of weird !
Did you tried other serial communication software ?

User avatar
RogerClark
Posts: 7187
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

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

Post by RogerClark » Mon Sep 12, 2016 9:56 pm

I wonder if this is a biproduct of the nee Tx Buffering ?

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

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

Post by martinayotte » Mon Sep 12, 2016 10:03 pm

It is a possibility,I didn't merged it yet in my environment.

But according to the code above, it would hang with 58 characters ...

@Phono, could you try to print a single very long print such as the following to see if hang at specific position ?

Code: Select all

Serial.println("012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789")

edogaldo
Posts: 283
Joined: Fri Jun 03, 2016 8:19 am

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

Post by edogaldo » Tue Sep 13, 2016 6:45 am

Hi Phono, a couple of questions:
  • are you using Serial over USART1 (using a usb2serial stick) or SerialUSB (direct connection with the board's usb)
  • which board are you using?

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 6:51 am

Following your advice, I have changed the code as follows :

#ifdef SERIAL
SERIAL.begin(9600);
delay(2000);
Serial.println("012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789");
SERIAL.println("Impression debug activee") ;
#else
CANSetup() ;
#endif

Ethernet.begin(mac,ip);
#ifdef SERIAL
SERIAL.print("Initialisation Client Ethernet, ") ;
SERIAL.print("Initialisation Client Ethernet 2, ") ;
SERIAL.println("Initialisation Client Ethernet 3") ;
#endif


I get the following printout :
012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
Impression debug activee
Initialisation Client Ethernet,

note : there is a space after the last comma.
It does the same thing if I change

SERIAL.print("Initialisation Client Ethernet, ") ;

to a println.
I checked wether it was related to the serial monitor. For so, I launched Teraterm and configured it for the port the maple board is on (COM4). I get exactly the same printout as above.

So I suppose that the problem stands in the usb part of the STM32 core.

edogaldo
Posts: 283
Joined: Fri Jun 03, 2016 8:19 am

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

Post by edogaldo » Tue Sep 13, 2016 7:12 am

Hi Phono, few questions:
  • which board are you using?
  • are you using Serial over USART1 (using a usb2serial stick) or SerialUSB (direct connection with the board's usb)?
  • if you make a very simple sketch like:

    Code: Select all

    begin() {
    Serial.begin(9600);
    delay(2000);
    Serial.println("012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789");
    Serial.println("Impression debug activee") ;
    Serial.print("Initialisation Client Ethernet, ") ;
    Serial.print("Initialisation Client Ethernet 2, ") ;
    Serial.println("Initialisation Client Ethernet 3") ;
    }
    does it hang as well?

Post Reply