DaisyDuino vs C++, performance difference?

Just getting started with the daisy patch submodule, and I was wondering if there is any downside in terms of speed/efficiency in using daisyduino over the barebones c++ and libdaisy?

Will DSP or things like spi communication take up more resources or be slower with Arduino?

Hi,
Unfortunately the Daisyduino implementation is restricted to 128 kB of code and therefore will soon be a dead end.

1 Like

You can do wonderful things in just 128k.

Why “soon”?

2 Likes

The downsides of Arduino are partly speed/efficiency but mostly because eventually it takes more work to use Arduino IDE compared to just using C.

You don’t really know what you are missing out on until you use something like CubeMX to set up an STM32 board and you realize that there is an entire universe that Arduino keeps hidden from you.

I had no idea what it kept hidden/ behind the scenes. I’d say if you are an artist who just wants to get one thing done using a microcontroller then Arduino is the better option, but if you are serious about learning microcontrollers then Arduino will end up confusing you long term.

I was a long time user of arduino for programming because it worked for me, and and I knew how to use it.

I’d go as far to say 128k is HUGE for a single micro controller program.
Unless you are using audio files 128k is more than enough for someone wanting to use the Arduino IDE.

1 Like

So I did make a comparison. Output a square wave at D22.

Arduino: code 57884 bytes, 5,49MHz
libDaisy: code 59876 bytes, 11,76MHz

It is astonishing, how much code space is needed on both. It should be possible to toggle a pin with just a few instructions? And a machine running at 400MHz should be able to do that a little bit faster?

#include "daisy_seed.h"
 
using namespace daisy;
using namespace daisy::seed;
 
DaisySeed hw;
 
int main(void) {
  // Initialize the Daisy Seed
  hw.Init();
 
  // Create our GPIO object
  //GPIO my_button;
  GPIO my_led;
 
  // Initialize the GPIO object for our button */
  //my_button.Init(D0, GPIO::Mode::INPUT, GPIO::Pull::PULLUP);
 
  // Initialize the GPIO object for our LED
  my_led.Init(D22, GPIO::Mode::OUTPUT);
 
  while(1) {
    my_led.Write(1);
    my_led.Write(0);
  }
}

==============================

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(22, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(22, HIGH);  // turn the LED on (HIGH is the voltage level)
  //delay(200);                      // wait for a second
  digitalWrite(22, LOW);   // turn the LED off by making the voltage LOW
  //delay(200);                      // wait for a second
}
2 Likes

Made a mistake, Arduino was not switched to O3 - fastest. So now we get:
Daisy Seed 400MHz, Arduino: code 59772 bytes, 5,8MHz
Daisy Seed 400MHz, libDaisy: code 59876 bytes, 11,76MHz
Teensy 4.1 @ 396MHz, Arduino: code ~22000 bytes, 5.8MHz

So regarding speed Daisyduino is as good as Teensy4.1@396MHz, but somehow needs 60kB for whatever instead of 22kB.

So now I have discovered, that there is digitalWriteFast in Teensy Arduino
Teensy 4.1 @ 396MHz, Arduino: code ~22000 bytes, 14.1MHz!
With DaisyDuino there is an error about pin numbering, when I try this.

Well, a good implementation of Arduino seems superior to libDaisy in this check about efficiency… :wink:

2 Likes