From 6bb5a024ab283b639ddc92d71ff3c9b86eebdcec Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Wed, 12 Aug 2020 14:16:57 +0200 Subject: [PATCH] Added FreeMem() debugging functions. --- MicroDexed.ino | 27 +++++++++++++++++++++++++++ config.h | 6 +++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index d25539b..4b29701 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -2162,6 +2162,8 @@ void show_cpu_and_mem_usage(void) Serial.print(peak_dexed_value, 1); Serial.print(F("|BLOCKSIZE:")); Serial.print(AUDIO_BLOCK_SAMPLES, DEC); + Serial.print(F("|RAM:")); + Serial.print(FreeMem(), DEC); Serial.print(F("|ACTVOICES:")); for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) @@ -2367,4 +2369,29 @@ void SerialPrintFormatInt3(uint8_t num) sprintf(buf, "%3d", num); Serial.print(buf); } + +/* From: https://forum.pjrc.com/threads/33443-How-to-display-free-ram */ +extern "C" char* sbrk(int incr); +uint32_t FreeMem(void) +{ + char top; + return &top - reinterpret_cast(sbrk(0)); +} +/* + uint32_t FreeMem(void) { // for Teensy 3.0 + uint32_t stackTop; + uint32_t heapTop; + + // current position of the stack. + stackTop = (uint32_t) &stackTop; + + // current position of heap. + void* hTop = malloc(1); + heapTop = (uint32_t) hTop; + free(hTop); + + // The difference is (approximately) the free, available ram. + return stackTop - heapTop; + } +*/ #endif diff --git a/config.h b/config.h index cff33c9..4e28fbd 100644 --- a/config.h +++ b/config.h @@ -56,7 +56,7 @@ // sed -i.orig 's/^#define USB_MIDI_SYSEX_MAX 290/#define USB_MIDI_SYSEX_MAX 4104/' /usr/local/arduino-teensy/hardware/teensy/avr/cores/teensy3/usb_midi.h //#define USB_MIDI_SYSEX_MAX 4104 -#define VERSION "1.0.7" +#define VERSION "1.0.8" //************************************************************************************************* //* DEVICE SETTINGS @@ -92,7 +92,7 @@ //************************************************************************************************* //* DEBUG OUTPUT SETTINGS //************************************************************************************************* -//#define DEBUG 1 +#define DEBUG 1 #define SERIAL_SPEED 230400 #define SHOW_XRUN 1 #define SHOW_CPU_LOAD_MSEC 5000 @@ -103,7 +103,7 @@ #define DEXED_ENGINE DEXED_ENGINE_MODERN // DEXED_ENGINE_MARKI // DEXED_ENGINE_OPL // Number of Dexed instances -#define NUM_DEXED 1 // 1 or 2 - nothing else! +#define NUM_DEXED 2 // 1 or 2 - nothing else! // FX-CHAIN ENABLE/DISABLE #define USE_FX 1 // CHORUS parameters