I have this problem too, I have a simple sketch that is supposed to toggle a pin a couple of times then loop forever to test execution speed but it won't run. Makes me want to revert to a standard C compiler so I have wysiwig and know what's running. This is mine:
void setup()
{
// put your setup code here, to run once:
pinMode(PB5, OUTPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
uint32_t Input_A = 1235;
uint32_t Input_B = 9876;
uint32_t Output;
digitalWrite(PB5, HIGH);
Output = Input_A * Input_B;
digitalWrite(PB5, LOW);
Output = Input_A / Input_B;
digitalWrite(PB5, HIGH);
while(1);
}
The idea is that there should be no ints, no fluff, just the code I put there.
I'm sorry, I'm not expecting to see on the LED (D13) anything significant beyond my pin toggles, but actually I do, when it powers up the LED blinks roughly the same as it did before I downloaded my sketch.
I did this same test program on an Infineon XMC and got (from memory) ~80us high and low which is the time to do the calculation plus the time to change the state of the I/O pin. On this it's like my script hasn't been downloaded as the LED blinks in the 50ms to 500ms range but there are no sub 1ms pulses I would have expected and after it gets to the while(1) I expect it to not be able to do anything else yet the LED occasionally flashes again as if I don't have the script loaded. Using serial is no good to me because the latency in the serial routines are not documented so I would need to set up timers to measure the time internally and I would not know what "fluff" there was in all that.
On the "optimised out" suggestion, in C I would use volatile so I will see if that's the case in Arduino as well. On an AVR using bare metal programming an I/O line set/reset should execute in 1 clock cycle so be negligible.
So anyway, the basic idea is set a pin, do something, clear the pin and measure the width on a scope to know run time for the given clock speed. In my example I was wanting to measure integer divide and multiply. in the same program.
I tested this again with volatile set for the output variable and it behaved the same, the LED gets pulsed by some internal startup functions (maybe in th BL) and then seems to do nothing further?
I would have expected it to do the 3 BL pulses then remain high until something else drives it which should be nothing because I left it high.
I'll give that a try, but it doesn't explain why an output pin when set and cleared doesn't do so in my code or why while(1); doesn't stop all IO activity.