Is I2S supported on Grand Central M4 Express ?
Can the audio examples, such as basic.ino run on this board ?
Do the classes in library file Adafruit_ZeroI2S.cpp work with the board, or is there some other alternative library to use ?
Thank you.
Is I2S supported on Grand Central M4 Express ?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Is I2S supported on Grand Central M4 Express ?
Which pins have you been using for i2s on the Grand Central M4?
It should work with the Adafruit_ZeroI2S library, but require a custom pin selection.
Looking at the CircuitPython code I see these pins being used with a Grand Central M4. Along with a report of a possible issue between different Grand Central Board Releases (Serial# 1119 vs.Serial# 3119)
viewtopic.php?p=813251&hilit=i2s+grand+central#p813251
It should work with the Adafruit_ZeroI2S library, but require a custom pin selection.
Looking at the CircuitPython code I see these pins being used with a Grand Central M4. Along with a report of a possible issue between different Grand Central Board Releases (Serial# 1119 vs.Serial# 3119)
Code: Select all
audiobusio.I2SOut(board.D14, board.D33, board.D32)
- 3pb
- Posts: 10
- Joined: Sat Aug 13, 2022 9:11 pm
Re: Is I2S supported on Grand Central M4 Express ?
With
or with
Pins 32 and 33 have appropriate signals.
Pin 14 never has a signal.
Also, does not generate a signal on pin 15.
Code: Select all
Adafruit_ZeroI2S i2s = Adafruit_ZeroI2S();
Code: Select all
Adafruit_ZeroI2S i2s = Adafruit_ZeroI2S(32, 14, 33, 31);
Pin 14 never has a signal.
Also,
Code: Select all
i2s.enableMCLK();
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Is I2S supported on Grand Central M4 Express ?
What is the serial# on your Grand Central?
Have you tried the dma_passthrough.ino example (M4 devices only)?
https://github.com/adafruit/Adafruit_Ze ... hrough.ino
Have you tried the dma_passthrough.ino example (M4 devices only)?
Code: Select all
/* This example shows how to pass data through using the
* ZeroI2S and ZeroDMA libraries.
*
* This example is for M4 devices only
*
* This uses a 24bit i2s slave device capable of both transmitting
* receiving data.
*
* Any data that the microcontroller receives via the I2S bus
* will be DMAd back out to the device.
*
* try this with the AK4556 I2S ADC/DAC
* https://www.akm.com/akm/en/file/datasheet/AK4556VT.pdf
*/
#include <Adafruit_ZeroI2S.h>
#include <Adafruit_ZeroDMA.h>
#include "utility/dma.h"
#include <math.h>
#ifndef __SAMD51__
#error "this example is for SAMD51 devices only"
#endif
/* max volume for 24 bit data */
#define VOLUME ( (1UL << 23) - 1)
/* create 2 buffers. One will transmit while the other gets filled */
#define BUFSIZE 128
int ping[BUFSIZE];
int pong[BUFSIZE];
//the buffer that's currently transmitting
int *txBuf;
/* we need one DMA channel for receive (RX),
* and another for transmit (TX)
*/
Adafruit_ZeroDMA txDMA;
Adafruit_ZeroDMA rxDMA;
DmacDescriptor *txDesc;
DmacDescriptor *rxDesc;
ZeroDMAstatus stat; // DMA status codes returned by some functions
Adafruit_ZeroI2S i2s;
void dummy_callback(Adafruit_ZeroDMA *dma) { } //do nothing
void setup()
{
Serial.begin(115200);
//while(!Serial); // Wait for Serial monitor before continuing
Serial.println("I2S throughput via DMA");
Serial.println("Configuring DMA triggers");
txDMA.setTrigger(I2S_DMAC_ID_TX_0);
rxDMA.setTrigger(I2S_DMAC_ID_RX_0);
txDMA.setAction(DMA_TRIGGER_ACTON_BEAT);
rxDMA.setAction(DMA_TRIGGER_ACTON_BEAT);
Serial.print("Allocating DMA channels...");
stat = txDMA.allocate();
txDMA.printStatus(stat);
stat = rxDMA.allocate();
rxDMA.printStatus(stat);
Serial.println("Setting up transfer");
txDesc = txDMA.addDescriptor(
ping, // move data from here
(void *)(&I2S->TXDATA.reg), // to here
BUFSIZE, // this many...
DMA_BEAT_SIZE_WORD, // bytes/hword/words
true, // increment source addr?
false);
txDesc->BANNED.bit.BLOCKACT = DMA_BLOCK_ACTION_INT;
txDesc = txDMA.addDescriptor(
pong, // move data from here
(void *)(&I2S->TXDATA.reg), // to here
BUFSIZE, // this many...
DMA_BEAT_SIZE_WORD, // bytes/hword/words
true, // increment source addr?
false);
txDesc->BANNED.bit.BLOCKACT = DMA_BLOCK_ACTION_INT;
txDMA.loop(true);
//this will be the initial tx buffer
txBuf = ping;
rxDesc = rxDMA.addDescriptor(
(void *)(&I2S->RXDATA.reg), // move data from here
pong, // to here
BUFSIZE, // this many...
DMA_BEAT_SIZE_WORD, // bytes/hword/words
false, // increment source addr?
true);
rxDesc->BANNED.bit.BLOCKACT = DMA_BLOCK_ACTION_INT;
rxDesc = rxDMA.addDescriptor(
(void *)(&I2S->RXDATA.reg), // move data from here
ping, // to here
BUFSIZE, // this many...
DMA_BEAT_SIZE_WORD, // bytes/hword/words
false, // increment source addr?
true);
rxDesc->BANNED.bit.BLOCKACT = DMA_BLOCK_ACTION_INT;
rxDMA.loop(true);
Serial.println("Adding callbacks");
txDMA.setCallback(dummy_callback);
rxDMA.setCallback(dummy_callback);
/* begin I2S on the default pins. 32 bit depth at
* 44100 samples per second
*/
i2s.begin(I2S_32_BIT, 44100);
/* uncomment this if your I2S device uses the MCLK line */
i2s.enableMCLK();
/* enable transmit and receive channels */
i2s.enableTx();
i2s.enableRx();
stat = rxDMA.startJob();
stat = txDMA.startJob();
}
void loop()
{
Serial.println("do other things here while your DMA runs in the background.");
delay(2000);
}
- 3pb
- Posts: 10
- Joined: Sat Aug 13, 2022 9:11 pm
Re: Is I2S supported on Grand Central M4 Express ?
I commented out the lines to get it to run.
Still, good output on pins 32 and 33, but nothing on 14 and 15.
Serial number 0A49678C535053384A202020FF151C37
Is it required to jumper pins 31 and 32 for this to run ?
Code: Select all
banned.bit.BLOCKACT
Still, good output on pins 32 and 33, but nothing on 14 and 15.
Serial number 0A49678C535053384A202020FF151C37
Is it required to jumper pins 31 and 32 for this to run ?
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Is I2S supported on Grand Central M4 Express ?
I looked into other options for bannd.bit.BLOCKACT, but of the four optional asssignment values they will either disable the channel or suspend it after operation is completed.
Would you be up for trying to install CircuitPython on this board to confirm that our example code works with your Grand Central M4? Note, pin D15 and D33 are not being used.
https://learn.adafruit.com/adafruit-i2s ... iring-test
The serial number I am interested in is the one printed on the board (not the processor). It should be either 3119 which works with D14, D33, D32 pins or 1119 which a forum user was having trouble make work. Both of these were CircuitPython.0x0 NOACT Channel will be disabled if it is the last block transfer in the transaction
0x1 INT Channel will be disabled if it is the last block transfer in the transaction and block interrupt
0x2 SUSPEND Channel suspend operation is completed
0x3 BOTH Both channel suspend operation and block interrupt
viewtopic.php?p=813251&hilit=grand+cent ... al#p813251I2SSCK0: #14
I2SSDO: #32
I2SSDI: #31
Would you be up for trying to install CircuitPython on this board to confirm that our example code works with your Grand Central M4? Note, pin D15 and D33 are not being used.
https://learn.adafruit.com/adafruit-i2s ... iring-test
- 3pb
- Posts: 10
- Joined: Sat Aug 13, 2022 9:11 pm
Re: Is I2S supported on Grand Central M4 Express ?
Serial
E315391
3321
Using Circuit Python, and the script below, anticipated signals appear on pins 32 and 33, but not on 14 or 15.
# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import time
import array
import math
import audiocore
import board
import audiobusio
tone_volume = 0.1 # Increase this to increase the volume of the tone.
frequency = 440 # Set this to the Hz of the tone you want to generate.
length = 8000 // frequency
sine_wave = array.array("h", [0] * length)
for i in range(length):
sine_wave = int((math.sin(math.pi * 2 * i / length)) * tone_volume * (2 ** 15 -1))
# For Feather M0 Express, ItsyBitsy M0 Express, Metro M0 Express
#audio = audiobusio.I2SOut(board.D1, board.D0, board.D9)
# For Feather M4 Express
# audio = audiobusio.I2SOut(board.D1, board.D10, board.D11)
# For Metro M4 Express
#audio = audiobusio.I2SOut(board.D3, board.D9, board.D8)
audio = audiobusio.I2SOut(board.D14, board.D33, board.D32)
sine_wave_sample = audiocore.RawSample(sine_wave)
while True:
audio.play(sine_wave_sample, loop=True)
time.sleep(1)
audio.stop()
time.sleep(1)
E315391
3321
Using Circuit Python, and the script below, anticipated signals appear on pins 32 and 33, but not on 14 or 15.
# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
#
# SPDX-License-Identifier: MIT
import time
import array
import math
import audiocore
import board
import audiobusio
tone_volume = 0.1 # Increase this to increase the volume of the tone.
frequency = 440 # Set this to the Hz of the tone you want to generate.
length = 8000 // frequency
sine_wave = array.array("h", [0] * length)
for i in range(length):
sine_wave = int((math.sin(math.pi * 2 * i / length)) * tone_volume * (2 ** 15 -1))
# For Feather M0 Express, ItsyBitsy M0 Express, Metro M0 Express
#audio = audiobusio.I2SOut(board.D1, board.D0, board.D9)
# For Feather M4 Express
# audio = audiobusio.I2SOut(board.D1, board.D10, board.D11)
# For Metro M4 Express
#audio = audiobusio.I2SOut(board.D3, board.D9, board.D8)
audio = audiobusio.I2SOut(board.D14, board.D33, board.D32)
sine_wave_sample = audiocore.RawSample(sine_wave)
while True:
audio.play(sine_wave_sample, loop=True)
time.sleep(1)
audio.stop()
time.sleep(1)
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Is I2S supported on Grand Central M4 Express ?
Thank you for loading the CircuitPython code and providing the PCB serial#'s.
Have you attempted connecting an i2s device to this configuration like the UDA1334?
What have you been measuring the pin output signals with (multimeter, scope, etc)?
The next step would be to open a case with the github repo showing the nearly "stock" example code you are running CircuitPython && Arduino and the signals you are seeing.
https://github.com/adafruit/Adafruit-Gr ... PCB/issues
Have you attempted connecting an i2s device to this configuration like the UDA1334?
What have you been measuring the pin output signals with (multimeter, scope, etc)?
The next step would be to open a case with the github repo showing the nearly "stock" example code you are running CircuitPython && Arduino and the signals you are seeing.
https://github.com/adafruit/Adafruit-Gr ... PCB/issues
- 3pb
- Posts: 10
- Joined: Sat Aug 13, 2022 9:11 pm
Re: Is I2S supported on Grand Central M4 Express ?
Thank you - I have on hand what appears to be a UDA1334A clone, but have not tried it yet.
I started working with a little PCM5102 card, which works fine with another microcontroller which is faster, and which supplies all 4 signals. The PCM5102 card fails with the Grand Central M4 Express. I started with Grand Central M4 Express because it has pretty good performance, and because the power, usb and reset are all at one end, and because it can work with a single 12-volt power supply, and supply a little regulated power to other chips. It's just a convenient physical package.
I've been measuring signals with an oscilloscope.
I started working with a little PCM5102 card, which works fine with another microcontroller which is faster, and which supplies all 4 signals. The PCM5102 card fails with the Grand Central M4 Express. I started with Grand Central M4 Express because it has pretty good performance, and because the power, usb and reset are all at one end, and because it can work with a single 12-volt power supply, and supply a little regulated power to other chips. It's just a convenient physical package.
I've been measuring signals with an oscilloscope.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: Is I2S supported on Grand Central M4 Express ?
This is starting to look like a viable HW issue for engineering to examine.
If you don't mind trying your UDA1334A clone to confirm that it does not work that would be a helpful datapoint before opening a github issue on the Grand Central M4 github repo.
If you don't mind trying your UDA1334A clone to confirm that it does not work that would be a helpful datapoint before opening a github issue on the Grand Central M4 github repo.
Please be positive and constructive with your questions and comments.