I haven't gotten the Keyword Spotting working yet, but since today is the deadline I thought I should summarize how far I've gotten.


ADC Timing

The impulse that I'm trying to use was sampled at 16KHz with 1 second windows.

The equation for sampling rate is:


where fCLK_ADC = processor clock/prescaler  --> processor clock is 48MHz

nSAMPLING is the number of clocks in the sampling period

nOFFCOMP is a fixed 4 clock sampling period (use either nOFFCOMP or nSAMPLING but not both)

nDATA is the number of bits (resolution)


So, with a prescaler value of 128 and a total of 23 clocks per sample would be about a 16.3 KHz sampling rate


I went to verify this on the scope.  I'm setting the DMA to transfer 16000 samples per buffer and toggle the signal between buffers.  For a 16 KHz sampling rate I should see a period of 2 seconds.

With 23 clocks per sample (nSAMPLING = 11 and nDATA = 12) I ended up with 2.04 seconds or about 15.7 KHz.

With 22 clocks per sample (nSAMPLING = 10 and nDATA = 12) I ended up with 1.96 seconds or about 16.3 KHz.


Not sure how much effect this will have but I'll try the higher sample rate.

The registers are set as follows:





Here is the scope capture:


The impulse partitions the 1 second sampling window into 4 slices, so my DMA buffers will hold 4000 samples each.


Error compiling with the impulse (model library)

Unfortunately there is a known problem with filename length using the Arduino IDE on Windows (32k character limit) that I had forgotten about, so I had problems compiling.

I had run into this problem when compiling the Nano 33 BLE Sense example and had to add a patch to the arduino hardware mbed library.

Luckily, Edge Impulse has a patch http://cdn.edgeimpulse.com/drivers/samd51-arduino/platform.local.txt for the samd51 that I added to the seeeduino hardware samd library.  The patch indicated that it is for an Adafruit samd51 but it seems to work for me.


Sample buffer overrun

This is where I am currently.  I think that I made some coding errors integrating the impulse library.  Hopefully I can find the errors by inspection, otherwise I'll need to think about how to debug the program.  Might be a problem understanding how the data is being handled.  Or maybe I made a mistake with the DMA.


I need to take some time off for other projects but I'll post when I get this figured out.




Links to related posts

Wio Terminal Sensor Fusion - Introduction

Wio Terminal Sensor Fusion - Sensor Integration

Wio Terminal Sensor Fusion - Remote Data Display and Control using Blynk

Wio Terminal Sensor Fusion - Remote Data Display and Control using Blynk continued

Wio Terminal Sensor Fusion - TinyML Keyword Spotting Part 1

Wio Terminal Sensor Fusion - TinyML Keyword Spotting Part 2