FFT/spectrum with Feather M0 & Sph0645

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

FFT/spectrum with Feather M0 & Sph0645

Post by carlocosta2009 »

Dear Staff,
I would like to ask for your kind help, as I'm trying to monitor the spectrum frequency from an I2S mems mic with the arduino IDE serial plotter.

In first place, I have few years of experience with arduino and microcontrollers (mainly 32u4 and esp32) and I feel somewhat comfortable in editing existing libraries. However, my knowledge of programming C++ is relatively basic and makers's level, not professional, and faraway from understanding all the code.

I have:
SPH0645LM4H (code 3421)
FEATHER M0 with Wifi (code 3010)
Alternately I also have a Feather ESP32.


Option A)
I followed this tutorial but I'm smashing against the Multiple definition of DMAC_Handler. As far as I read in this forum, no way to overcome it.
https://learn.adafruit.com/adafruit-i2s ... g-and-test
-Kindly, what type of boards are compatible with my I2S mic and the spectrum analyzer of the arduino sound library?


Option B)
I installed the Audio Adafruit library fork, but the FFT sketch does not compile for Feather M0, giving the following output:

C:\Users\......\Documents\Arduino\libraries\Audio_-_Adafruit_Fork/effect_delay.h:44:35: error: division by zero in #if
44 | #define DELAY_QUEUE_SIZE (6144 / AUDIO_BLOCK_SAMPLES)
C:\Users\......\Documents\Arduino\libraries\Audio_-_Adafruit_Fork/effect_delay.h:106:5: note: in expansion of macro 'DELAY_QUEUE_SIZE'
106 | #if DELAY_QUEUE_SIZE * AUDIO_BLOCK_SAMPLES < 65535

I tried to change the instructions in the file effect_Delay.h, but other errors come up.
-Kindly, any idea of how to solve it via software?
-Is this compatible with i2s mic and Feather M0?


Option C)
The third option is the FFT Test sketch of the library Adafruit Zero FFT library, which compiles, but has no interaction with the microphone.


I look forward to your kind reply with suggestions on where to focus my effort and eventually whether you recommend further hardware (mic, board..)

Thank you in advance.
Carlo
Attachments
hardware available
hardware available
Inked20210510_205224_LI.jpg (845.32 KiB) Viewed 1355 times

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: FFT/spectrum with Feather M0 & Sph0645

Post by adafruit_support_mike »

Option A is the one you want.

Post the exact error messages you get when you try to compile that code (between CODE tags please).

User avatar
carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

Re: FFT/spectrum with Feather M0 & Sph0645

Post by carlocosta2009 »

Mike,

Thank you for your quick reply.

The sketch is the default "SpectrumSerialPlotter" of the Arduino Sound Library, latest version 0.2.1
Arduino IDE version: 1.8.13
Adafruit_ZeroDMA version: 1.08

The compiling error is the following:

Code: Select all

 c:/users/carlo/appdata/local/arduino15/packages/adafruit/tools/arm-none-eabi-gcc/9-2019q4/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: libraries\Adafruit_Zero_DMA_Library\Adafruit_ZeroDMA.cpp.o: in function `DMAC_Handler':
C:\Users\carlo\BANNED\Documents\Arduino\libraries\Adafruit_Zero_DMA_Library/Adafruit_ZeroDMA.cpp:119: multiple definition of `DMAC_Handler'; libraries\I2S\utility\DMA.cpp.o:C:\Users\carlo\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.7\libraries\I2S\src\utility/DMA.cpp:418: first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Errore durante la compilazione per la scheda Adafruit Feather M0. 

Grateful in advance for your kind support.
Regards

Carlo

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: FFT/spectrum with Feather M0 & Sph0645

Post by adafruit_support_mike »

Try removing the Zero_DMA library, or putting a ‘-‘ at the beginning of the folder name to keep the Arduino IDE from loading that library when it starts up. That should eliminate the conflict.

User avatar
carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

Re: FFT/spectrum with Feather M0 & Sph0645

Post by carlocosta2009 »

Hi Mike,

I made a fresh new installation of all, and removed the library Adafruit-zeroDma.
Now the compiling error is the below:

Code: Select all

In file included from C:\Program Files (x86)\Arduino\libraries\SD\src\utility\Sd2Card.cpp:31:
C:\Users\user\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.8\libraries\SPI/SPI.h:24:10: fatal error: Adafruit_ZeroDMA.h: No such file or directory
   24 | #include <Adafruit_ZeroDMA.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Error compiling for board Adafruit Feather M0.

I tried to comment out the referring code-instruction in both the Sd2Card.cpp and/or SPI.h, but this triggers further (many more) compiling errors for nested instructions.
I'm not planning to use neither SD nor SPI on this simple application.

I look forward to further kind suggestions.
Regards
Carlo

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: FFT/spectrum with Feather M0 & Sph0645

Post by adafruit_support_mike »

Hmm.. do you have a library named 'I2S' in your 'libraries' folder?

User avatar
carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

Re: FFT/spectrum with Feather M0 & Sph0645

Post by carlocosta2009 »

Dear Mike,
Thank you for your kind reply.

I confirm there is the library I2S version 1.0 in the following folder:
AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.8\libraries\


Carlo

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: FFT/spectrum with Feather M0 & Sph0645

Post by adafruit_support_mike »

Try removing that one and replacing the Zero_DMA library.

The error is telling you that the compiler sees a conflict between the two libraries. You should only need one.

User avatar
carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

Re: FFT/spectrum with Feather M0 & Sph0645

Post by carlocosta2009 »

Mike,

Removing the library I2S, the terminal gives:

Code: Select all

C:\Users\user\Documents\Arduino\libraries\ArduinoSound\src\AudioInI2S.cpp:19:10: fatal error: I2S.h: No such file or directory
   19 | #include <I2S.h>
      |          ^~~~~~~
compilation terminated.
exit status 1
Error compiling for board Adafruit Feather M0.

I also tried to remove the DMAC definition at the end of the file
AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.8\libraries\I2S\src\I2S.cpp

Code: Select all

#else
  void DMAC_Handler() {
    DMA.onService();
  }
which gives no compiling error.
I'm going to load the code into the board shortly and then post the feedback.

User avatar
carlocosta2009
 
Posts: 8
Joined: Tue Sep 13, 2016 10:01 am

Re: FFT/spectrum with Feather M0 & Sph0645

Post by carlocosta2009 »

Mike,

I confirm that the sketch compiles and uploads, but the Serial Monitor/Plotter won't output anything at the selected frequency.
It did not work commenting out this from the file AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.6.8\libraries\I2S\src\utility\DMA.cpp.

Code: Select all

#else
  void DMAC_Handler() {
    DMA.onService();
  }
Nothing from the serial monitor or plotter.

And neither adding the following to the Adafruit_ZeroDMA.cpp into the DMAC_Handler definition

Code: Select all

DMA.onService();

Code: Select all

DMAClass DMA;
Thank you in advance for any other comment or advice you could give.
Regards

User avatar
skuenstler
 
Posts: 8
Joined: Tue Nov 17, 2015 6:00 am

Re: FFT/spectrum with Feather M0 & Sph0645

Post by skuenstler »

Very same problem here - did you ever find a solution to this DMA issue with the I2S microphone on an M0 ??

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”