I'm trying to get my Arduino MKR WiFi 1010 to receive data from a 2 channel 24 bit ADC. The ADC communicates with I2S and the MKR WiFi is I2S compatible. The frequrency has to be very accurate, so an external clock from a timing module handles the ADC to run at 48 kHz. Now to my question. How does the I2S.read() work??
I2S.begin(I2S_PHILIPS_MODE, 24);
int sample = 0;
char data[3];
void myInterrupt(){ //Triggered by the external clock??
sample = I2S.read(); //How can this read a whole integer??
data[0]=(sample & 0xff);
data[1]=(sample>>8 & 0xff);
data[2]=(sample>>16 & 0xff);
**The data is then sent through WiFi to another unit**
}
int I2SClass::read(void* buffer, size_t size)
{
if (_state != I2S_STATE_RECEIVER) {
enableReceiver();
}
uint8_t enableInterrupts = ((__get_PRIMASK() & 0x1) == 0);
// disable interrupts,
__disable_irq();
int read = _doubleBuffer.read(buffer, size);
if (_dmaTransferInProgress == false && _doubleBuffer.available() == 0) {
// no DMA transfer in progress, start a receive process
_dmaTransferInProgress = true;
DMA.transfer(_dmaChannel, i2sd.data(_deviceIndex), _doubleBuffer.data(), _doubleBuffer.availableForWrite());
// switch to the next buffer for user output (will be empty)
_doubleBuffer.swap();
}
if (enableInterrupts) {
// re-enable the interrupts
__enable_irq();
}
return read;
}
There is a separate section of the Forum for MKR Boards where I don't go so I would not have wasted my time with a silly question and you would not have had to waste your time answering it.
I am suggesting to the Moderator to move your Thread to that section.
Robin2:
There is a separate section of the Forum for MKR Boards where I don't go so I would not have wasted my time with a silly question and you would not have had to waste your time answering it.
I am suggesting to the Moderator to move your Thread to that section.
...R
Well, since I2S is not only for the MKR boards I didn't want to limit my answers. You don't have to be so rude about it.