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
Normal Topic Using SW debugger breaks Digital Input (Read 1957 times)
Julle
Junior Member
**
Offline


Posts: 15
Location: Denmark
Joined: Oct 7th, 2015
Using SW debugger breaks Digital Input
Jun 29th, 2018 at 9:05pm
Print Post  
Hi.

I have made a really simple sample code, to test a push button with a LED.
The LED will flash every second, based on the Arduino Example "Blink without delay".

Then I just added an extra digital input, where I can minotor the input in the serial monitor.

This works, as long as I disable "Automatic Debugging". If I enable it, the code can still run, but the digital input now behaves as if it was floating (which it is not...).

Any idea?

Code (C++)
Select All
/*
Test with 5-pin Led+Push button.

Flash the LED every 1 s.
Read the button state and print to serial.

NB; needs an external pull down on pin 'pushButtonPin'. Works with 4.7k.
*/

// constants won't change. Used here to set a pin number:
const int ledPin = 5;					// the number of the LED pin
const int pushButtonPin = 6;
const long interval = 1000;				// interval at which to blink (milliseconds)

int ledState = LOW;						// ledState used to set the LED
unsigned long previousMillis = 0;       // will store last time LED was updated

void setup() {
	// set the digital pin as output:
	pinMode(ledPin, OUTPUT);
	pinMode(pushButtonPin, INPUT);

	Serial.begin(9600);
}

void loop() {
	// check to see if it's time to blink the LED; that is, if the difference
	// between the current time and last time you blinked the LED is bigger than
	// the interval at which you want to blink the LED.
	unsigned long currentMillis = millis();

	// LED stuff
	if (currentMillis - previousMillis >= interval) {
		// save the last time you blinked the LED
		previousMillis = currentMillis;

		// if the LED is off turn it on and vice-versa:
		if (ledState == LOW) {
			ledState = HIGH;
		}
		else {
			ledState = LOW;
		}

		// set the LED with the ledState of the variable:
		digitalWrite(ledPin, ledState);
	}

	// Push button
	int buttonState = digitalRead(pushButtonPin);
	Serial.println(buttonState);
}

 

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using SW debugger breaks Digital Input
Reply #1 - Jun 29th, 2018 at 10:20pm
Print Post  
fyi: Switching off automatic debugging is the same as switching the toolbar between Debug and Release

Please ensure vmicro>debugger>digital and analog pin reporting is off

Which board are you using?
  
Back to top
WWW  
IP Logged
 
Julle
Junior Member
**
Offline


Posts: 15
Location: Denmark
Joined: Oct 7th, 2015
Re: Using SW debugger breaks Digital Input
Reply #2 - Jul 1st, 2018 at 5:43pm
Print Post  
Tim@Visual Micro wrote on Jun 29th, 2018 at 10:20pm:
fyi: Switching off automatic debugging is the same as switching the toolbar between Debug and Release

Yes, I figured that out. It was more a concern that my code was behaving differently. 

Tim@Visual Micro wrote on Jun 29th, 2018 at 10:20pm:
Please ensure vmicro>debugger>digital and analog pin reporting is off

These seems to be already off. Was is this feature doing?

Tim@Visual Micro wrote on Jun 29th, 2018 at 10:20pm:
Which board are you using?

Micro Pro, ATmega32U4 5V 16MHz.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using SW debugger breaks Digital Input
Reply #3 - Jul 1st, 2018 at 7:36pm
Print Post  
Thanks for the info. The auto reports simply read the pin states which isn't really an issue but better OFF for a simpler test.

The debugger statements are pretty crude. They just uses serial to send/receive and other standard syntax such as delay() or millis() etc. Not much more than you use in your code and will not reference other pins unless you have breakpoint code that do that.

The "compiler>show build folder" will give you a link to the build folder after each build. What the debugger does can be viewed in the temp code.

Sorry i can't be more help. It's a strange one.

  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint