Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) Serial monitor resets the program (Read 14378 times)
Gilles Plante
Full Member
***
Offline


Posts: 156
Location: Québec, Canada
Joined: Oct 31st, 2013
Serial monitor resets the program
Mar 15th, 2014 at 8:06pm
Print Post  
It's Saturday, and I work because development is late...

On top of that, I get some weird, and unwanted,  gltches  Shocked.

At the begging of loop(), and only once, I write something to Serial (the port used to upload the program). After a re-upload of the program, I don't get on the Serial monitor what I should read. Sometimes, closing and restarting the Serial monitor is enough for my friend (?) to display what I sent...

And closing and restarting the Serial monitor resets the board  Huh.

EDIT

One more glitch. When the Serial monitor is displayed, and I upload With Debug:
  • I am not told a Debug Session is already running... and the added breakpoints are not executed
  • To get the message that a Debug Session is already running... I need to first close the Serial Monitor, and then the new breakpoints do their job.
Just what is going on ??? Are Sherlock and Dr Watson free to come up to my place ? By the way, this new Sherlock TV show is quite a great show  Smiley.

AtmelStudio: 6.1   VisualMicro: 1.1401.26

Thanks
« Last Edit: Mar 15th, 2014 at 8:19pm by Gilles Plante »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial monitor resets the program
Reply #1 - Mar 15th, 2014 at 8:12pm
Print Post  
Hi Gilles,

I think you have to be dr watson  Smiley

Quote:
And closing and restarting the Serial monitor resets the board


Untick Dtr on the Serial Monitor to prevent the auto-reset

Quote:
At the begging of loop(), and only once, I write something to Serial (the port used to upload the program). After a re-upload of the program, I don't get on the Serial monitor what I should read. 


If you are saying you send serial only once then it is possible the arduino is re-starting so quickly that Visual Micro can not open the serial port fast enough. Please try a delay(3000) in the setup() to see if this helps.

Thanks
  
Back to top
IP Logged
 
Gilles Plante
Full Member
***
Offline


Posts: 156
Location: Québec, Canada
Joined: Oct 31st, 2013
Re: Serial monitor resets the program
Reply #2 - Mar 16th, 2014 at 6:23pm
Print Post  
Quote:
Please try a delay(3000) in the setup() to see if this helps.

Some more info about my environment:
  • Uploading of programs is through Serial
  • The debugger is set to use Serial also
  • I have an XBee module connected to Serial1
Yesterday I added code that checks the ID, MY, and DK settings in the XBee: if they are wrong then I write the proper settings. All of this is through AT commands. This is done in setup(). And this is when those issues started  Shocked.

The serial ports look to be very finicky on Arduino... One out of two AT commands to the XBee fail, and I just don't get why  Cry. The same code works fine on another type of MCU.

Regarding delay(), it's not recommended to use it but for very short delays. Thing is, delay() freezes the MCU for the duration of the delay. I created a Wait() function that simply spends time for the duration of the delay:

Code
Select All
while(Var > millis()) ; 


It didn't help...

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial monitor resets the program
Reply #3 - Mar 16th, 2014 at 6:36pm
Print Post  
Hi,

Thanks for the info. The delay was just a test not a suggestion for a permanent solution but in the setup() method that only executes once it is not a major problem.

I'll have to dig out my xbee's sometime. Often the xbee needs a delay between commands.

  
Back to top
IP Logged
 
Gilles Plante
Full Member
***
Offline


Posts: 156
Location: Québec, Canada
Joined: Oct 31st, 2013
Re: Serial monitor resets the program
Reply #4 - Mar 16th, 2014 at 7:02pm
Print Post  
Tim,

is it possible that for some reason working with serial ports from within setup() could lead to issues ?

Thanks
  
Back to top
 
IP Logged
 
Gilles Plante
Full Member
***
Offline


Posts: 156
Location: Québec, Canada
Joined: Oct 31st, 2013
Re: Serial monitor resets the program
Reply #5 - Mar 17th, 2014 at 6:41pm
Print Post  
The issue with AT commands was in my code   Embarrassed. It's only when I printed the code that it I saw it.

I replaced at the beginning of loop() prints to Serial by breakpoints with 'When hit'. To get the output in the Debug Message window, once the program is reset, I need to close the Serial Window, bring it back on, and then the data appears in the window, strangely as if the program was waiting for that (close and reopen the Serial window) before executing  Undecided.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial monitor resets the program
Reply #6 - Mar 17th, 2014 at 7:45pm
Print Post  
Strange. Are you debugging on Serial1 using the xbee?
  
Back to top
IP Logged
 
Gilles Plante
Full Member
***
Offline


Posts: 156
Location: Québec, Canada
Joined: Oct 31st, 2013
Re: Serial monitor resets the program
Reply #7 - Mar 17th, 2014 at 8:58pm
Print Post  
Nope,

I debug on Serial (Serial0).
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial monitor resets the program
Reply #8 - Mar 17th, 2014 at 9:34pm
Print Post  
Questions not to cause you to change setup, I just need the answers  Smiley

Have you got project debug break/pause enabled?
Is Dtr on or off on the serial window?
What speed are you using Serial at?
Does your code do anything with serial0?

Thanks
  
Back to top
IP Logged
 
Gilles Plante
Full Member
***
Offline


Posts: 156
Location: Québec, Canada
Joined: Oct 31st, 2013
Re: Serial monitor resets the program
Reply #9 - Mar 17th, 2014 at 9:52pm
Print Post  
Have you got project debug break/pause enabled?
   I always forget where I get this  Embarrassed 

Is Dtr on or off on the serial window?
    Not checked

What speed are you using Serial at?
    57600

Does your code do anything with serial0?
    No Serial.print, only through breakpoints
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial monitor resets the program
Reply #10 - Mar 17th, 2014 at 9:54pm
Print Post  
Break/Pause is in the project properties near the top. Press the yellow "?" on the vm tool bar and the properties should open as well as the explorer. 

Does your sketch code initialize serial 0 at 57600 or the xbee or both?

Thanks

  
Back to top
IP Logged
 
Gilles Plante
Full Member
***
Offline


Posts: 156
Location: Québec, Canada
Joined: Oct 31st, 2013
Re: Serial monitor resets the program
Reply #11 - Mar 17th, 2014 at 10:08pm
Print Post  
Quote:
Break/Pause is in the project properties near the top. Press the yellow "?" on the vm tool bar and the properties should open as well as the explorer.
I get only the Arduino Explorer.

Quote:
Does your sketch code initialize serial 0 at 57600 or the xbee or both?
Both of them

I realized that Reconnect was not checked. Now that it is, the Display switch to  Micro Debug Message right away and display what I am looking for.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial monitor resets the program
Reply #12 - Mar 17th, 2014 at 10:21pm
Print Post  
The properties are probably collapsed on a tab or button in your ide. You will find them but the wiki also shows how to access project properties.

Okay so it sounds like it is working now. It was disconnecting after you pulled the power/usb or uploaded? 

The Arduino ide expects the serial monitor to be re-opened after the hardware disconnects but Visual Micro allows an intelligent auto re-connect or manual by toggling the "connected" check box.

If your sketch code is not using serial0 then why is it initializing serial0? You must have also set the LocalSpeed project property to 57600 otherwise the debug would not be working because it defaults to 115k
  
Back to top
IP Logged
 
Gilles Plante
Full Member
***
Offline


Posts: 156
Location: Québec, Canada
Joined: Oct 31st, 2013
Re: Serial monitor resets the program
Reply #13 - Mar 18th, 2014 at 7:36pm
Print Post  
Tim,

I finally got back the Properties window. Enable Break/Pause is true.

Quote:
If your sketch code is not using serial0 then why is it initializing serial0?
Excellent question ! In the beginning, I was not using VisualMicro debugging features, so I sued printf() to serial0. Now I use VisualMicro debugger.

Is it a good or bad idea to setup serial0 at the beginning ? I think about the fact that the board will get flashed with Release not Debug mode.

Thanks
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Serial monitor resets the program
Reply #14 - Mar 19th, 2014 at 12:11pm
Print Post  
It doesn't matter if you use Serial.begin() in your code but it does mean that your project settings LocalSpeed and RemoteSpeed must use the speed that your code sets. Your code overrides the default Visual Micro speed setting of 115200 Break/Pause is on and Dtr is Off you have to pay more attention to the state of the Arduino. It is possible for the Arduino to have started before the debugger starts and also for the Arduino to be in the middle of running code when the debugger starts. You specificially requested that the Arduino does not re-boot when the debugger starts so you have a more complex situation to deal with. 

If the Arduino is stuck at a breakpoint before the debugger starts then the debugger will not know about it. So the Arduino will be in break/pause and Atmel Studio (or Vs) will appear to be doing very little. In this case you can use the Serial Monitor to send a C char. 'c' means Continue and this is what Visual Micro sends to the Arduino to tell it to continue from a breakpoint (F5 does this when in a break). yes it is a simple system  Smiley

Prior to switching off Dtr I think you reported the same problem. Again this will be the break/pause has been hit before the debugger had time to start-up. Normally this is not possible because the Dtr forces a re-boot when the debugger starts but it appears you have changed some of the default settings that will affect this. 

So I suggest you zip and email the Visual Micro folder below you sketch so that I can see your settings.

Thanks
« Last Edit: Mar 19th, 2014 at 1:40pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Gilles Plante
Full Member
***
Offline


Posts: 156
Location: Québec, Canada
Joined: Oct 31st, 2013
Re: Serial monitor resets the program
Reply #15 - Mar 19th, 2014 at 3:25pm
Print Post  
Tim,

hum not simple  Huh.

All that may explain or not an issue I have.

In setup(), the configuration of the XBee, connected to Serial1, is checked (AT commands). If wrong, then I reset the configuration. To work, I have to read parameters in the XBee.

It's a program compiled for debug that resides in the MCU:
  • If I reset the board via the Reset switch, all is fine
  • But if I simply plug in the board, that part of the of setup() fails, because I can't read the XBee (no answer from the XBee - my routine times out  Embarrassed

I have a few theories when the board is powered on:
  • The board does not reset properly, then Serial ports acts strangely. But I have while (!Serial1) ; so that does should not be an issue
  • The XBee does not reset properly
  • All of the Arduino reset and debugger start creates my issue 

The same issue occurs when I upload the program to the board.

I am puzzled  Embarrassed.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint