marcel-licence / ml_synth_basic_example

Arduino polyphonic synthesizer project (not a Moog) for ESP32 - STM32 - Teensy and more
GNU General Public License v3.0
33 stars 8 forks source link

Enhancment: Use Second Core on RP2040 #3

Closed bradanlane closed 1 year ago

bradanlane commented 1 year ago

The RP2040 uses the Arduino_Pico environment which provides easy support for running code on the second core.

The standard Arduino functions setup() and loop() run on the first core. The second core runs setup1() and loop1().

As a test, I moved the LED blink 1hz to the second core and used the data communications provided by rp2040.fifi.push_nb(), rp2040.fifi.pop_nb(), and rp2040.fifi.available() to signal the second core when the first core was finished with its initialization.

More details are available here: https://arduino-pico.readthedocs.io/en/latest/multicore.html

(this enhancement would be applicable to all of the projects built for the RP2040)

marcel-licence commented 1 year ago

It is intentional that I try to use only one core for all time critical tasks to leave the second core free for other users to use for all other tasks. The ESP32 code works similar. For example the display is driven by the second core. Thank you very much for your input

bradanlane commented 1 year ago

That makes sense. I was thinking the second core would be used for non-time-critical tasks, similar to the ESP32.

I only used the LED as my test to verify the design actually worked.

marcel-licence commented 1 year ago

I made also tests with a display which cannot be updated within the audio loop without any audible noise. Using loop1() does work. I may be possible that using different libraries will create different results. Can this issue be closed?

bradanlane commented 1 year ago

This can be closed. I will keep it in mind for future work.

Based on my initial investigations, I will likely switch from the RP2040 to an ESP32-S3 for my hardware design.

marcel-licence commented 1 year ago

Did you find a way to run the internal DAC with DMA on the S3? I wanted to get it running on the S2 but seems the IDF is still under development.

bradanlane commented 1 year ago

I will plan to use I2S and an external module (similar to your prior projects). I have not yet chosen the external chip.

marcel-licence commented 1 year ago

Usually I prefer using an external codec too. This experiment using PWM should give anyone a chance to get sound their setup with less effort