PDA

View Full Version : Porting the Audio lib to the SAMD21 based Arduinos



MickMad
08-08-2016, 10:44 AM
Hi there,

I'm going to port the Audio Library to work on the new SAMD21 based Arduinos and Arduino-compatible boards.

Since the SAMD21 family has I2S it makes sense to try and port this lib to work with those MCUs as well.

Major caveats:

SAMD21 family does not have the hardware DSP instructions, so those are going to be emulated in software (with very fast ASM routines maybe).

SAMD21 family does not have a Software ISR, unlike the Kinetis K20 family; the main object behind the Audio lib, that is the AudioStream object (defined in the Teensy core) makes use of this software ISR to update all the audio packets at the same time; in fact whenever you call AudioInterrupts() and AudioNoInterrupts() you are actually enabling or disabling that ISR.

Other than that, the SAMD21 has a pretty cool DMAC system so it won't be that much of a problem to port DMA code (most objects, especially the main controls - I2S i/o, DAC, PMW - use DMA to reduce CPU usage during data transfers).

So... who wants to jump in?

MickMad
08-09-2016, 10:22 AM
OK,

So...what if I emulate the Software ISR by using a pin interrupt? That should do the trick, right?

EDIT: I was wondering, do you think this post is legit to stay here or maybe it should just be moved on the official Arduino forum? I don't know what's the forum policy about this situation. Maybe I should leave a post here that references the Arduino forum post? Help me out

DerekR
08-10-2016, 01:21 AM
The audio library is built specifically for the Teensy Audio board with the SGTL500 codec. Are you proposing to develop an equivalent shield?

MickMad
08-10-2016, 10:08 AM
The audio library is built specifically for the Teensy Audio board with the SGTL500 codec. Are you proposing to develop an equivalent shield?

I'd rather say that the audio library is built specifically to work with any I2S codec. The library does not depend on the strict usage of the Audio Board w/ the SGTL500 CODEC; in fact you could use the Audio library with a Teensy without any CODEC at all, by using the builtin ADC for input and the DAC or PWM for output.

With that said, I already built a CODEC board using the AK4558 and it's already supported by the Audio library, so the idea of an equivalent shield (maybe even better) it's not remote.

PaulStoffregen
08-11-2016, 04:47 PM
Can't say I'm excited to port the code to non-Teensy boards. It's open source, so of course this is bound to happen eventually. Just don't expect me to be supportive or interested in helping.

MickMad
08-11-2016, 04:51 PM
Can't say I'm excited to port the code to non-Teensy boards. It's open source, so of course this is bound to happen eventually. Just don't expect me to be supportive or interested in helping.
Seems legit for me. I was thinking that maybe this thread could also be closed since pretty much everything is related to another architecture.