I’ve been wondering exactly how fast the Spark Core sketches will run. Since the STM32 is running at 72MHz right? I thought it should be blazing away… I was hoping that it would at least be as fast as an Arduino Uno in how it executes a sketch.
Just as a simple test, I’m running this sketch:
void setup()
{
pinMode(D7,OUTPUT);
}
void loop()
{
digitalWrite(D7,HIGH);
digitalWrite(D7,LOW);
digitalWrite(D7,HIGH);
digitalWrite(D7,LOW);
digitalWrite(D7,HIGH);
digitalWrite(D7,LOW);
digitalWrite(D7,HIGH);
digitalWrite(D7,LOW);
}
This just bangs away as fast as it can… and what I’m seeing is:
High for 2.05 microseconds.
Low for 2.05 microseconds.
(repeats 4 times)
But then there is a long delay from the end of the loop() back to the start of the loop() for 5 to 6.5 milliseconds. This number bumps around quite randomly, I’m assuming as background cloud tasks are interrupting for more or less time.
This basically means the fastest loop execution is about 200 times per second, which is pretty slow for such a beefcake micro like the STM32.
I wanted to perform some direct port manipulation from the Sketch as well like you can in an arduino to really test the clock speed, but I wasn’t sure how to do this on the Core. Is there a way to essentially do bit banging directly from the sketch, like you can with the arduino.
Could you guys please tell me if what I’m seeing is correct, and if so is this as fast as we can expect sketches to run? I know various peripherals that are handled via STM32 hardware (SPI, I2C and networking) would probably not suffer from this loop() delay, but a real time executive of 1ms tick is pretty standard for low end micros and it seems like we’d only reliably be able to create a 7ms tick without running out of real-time.