It looks like the model is good, and I flashed the firmware, adding the model to the firmware from github. However, looking at the Serial output, it doesn’t look like it is performing inference (or looping):
OK, making progress! It turns out the upload script only uploads the sketch bin file and not the NN bin file (ei_model.bin) so that’s why it wasn’t performing inference. Once I borrowed the firmware loader bat file (just replacing the firmware and model files with my own) I have the board running inference.
What I’m trying to do is play a wav file once a keyword is spotted. I have the code working correctly as a standalone sketch, but when I try to put it into the on_classification_changed method, the code hangs. I’m wondering if there is a timing/mutex thing that is preventing the wav file from playing. Any suggestions? For example, here is what i have in my code:
Hi Aurelien, thanks for the suggestion. It looks like I’m getting the same behavior. I did some more debugging and it looks like the hang up is in the audio code timer interrupt registers:
void AudioZeroClass::tcConfigure(uint32_t sampleRate)
// Enable GCLK for TCC2 and TC5 (timer counter input clock)
GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_TC4_TC5)) ;
// Set Timer counter Mode to 16 bits
TC5->COUNT16.CTRLA.reg |= TC_CTRLA_MODE_COUNT16;
// Set TC5 mode as match frequency
TC5->COUNT16.CTRLA.reg |= TC_CTRLA_WAVEGEN_MFRQ;
TC5->COUNT16.CTRLA.reg |= TC_CTRLA_PRESCALER_DIV1 | TC_CTRLA_ENABLE;
TC5->COUNT16.CC.reg = (uint16_t) (SystemCoreClock / sampleRate - 1);
// Configure interrupt request
// Enable the TC5 interrupt request
//*** code is hanging here ***
TC5->COUNT16.INTENSET.bit.MC0 = 1;
The strange thing is that this code runs standalone. When I try to integrate it with the Edge Impulse firmware, it hangs up. Guessing it’s an issue between the EI firmware timer and the audio timer? Any SAMD21 register experts that you are aware of? Thanks!
So it looks like the timer is still running, only the interrupt’s callback is disabled. I’ve checked a bit more the SAMDtimer library used by Syntiant and using timer4.enable(false) instead may do the trick.
If you are in touch with Syntiant, their support may be able to help on this as well.