elektrojohn
Member
Hi together,
currently I am working on a recording device for ultrasonic sounds with a sampling rate of 500 kS/s.
The ADC is a 16 bit ADC from Michrochip with 1MS/s sampling rate and an SPI interface.
To be able to use the Audio library I created my own input class by modifying the input_i2s class.
I am able to read and record audio signals at 500 kS/s. So far so good.
My idea was to use the MQS output as a monitoring output just to hear if the mike is working or not.
But I am encountering a very strange behaviour. The MQS outputs delivers output signal even if it is not configured at all.
I'm using this simple test sketch:
The MQS is not configured. No patch cable connected, nothing.
But I can hear the input signal on the headphone. This is not what I want because I need to do some audio processing before outputting the signal to the headphones..
What I found out is that the the transfer from the input to the MQS is not done by DMA.
Even if I disable DMA transfer (comment out all related code), the effect is still there.
At the end of the method begin() of the Spi input class I added the following lines:
As soon I comment out the lines handling I2S1_RCR4, the effect disappears. There must be some kind of internal
hardware connection between I2S1 I am using to read the ADC and I2S3 which is used for MQS.
Does anybody here has an advice or an idea how to fix this?
I appreciate any advice or reply, I'm lost with this issue at the moment.
In the attachment I added the full code of the modified input class.
Best
Christian
currently I am working on a recording device for ultrasonic sounds with a sampling rate of 500 kS/s.
The ADC is a 16 bit ADC from Michrochip with 1MS/s sampling rate and an SPI interface.
To be able to use the Audio library I created my own input class by modifying the input_i2s class.
I am able to read and record audio signals at 500 kS/s. So far so good.
My idea was to use the MQS output as a monitoring output just to hear if the mike is working or not.
But I am encountering a very strange behaviour. The MQS outputs delivers output signal even if it is not configured at all.
I'm using this simple test sketch:
Code:
#include <Arduino.h>
#include <Audio.h>
//control pre amplifier
#define PIN_AMP_0 15 // enable feedback resistor
#define PIN_AMP_1 29 // enable feedback resistor
#define PIN_AMP_2 16 // enable feedback resistor
#define PIN_AMP_3 30 // bridge high pass
AudioInputSpiMono m_audioIn; // SPI input
void setup() {
pinMode(PIN_AMP_0, OUTPUT);
pinMode(PIN_AMP_1, OUTPUT);
pinMode(PIN_AMP_2, OUTPUT);
pinMode(PIN_AMP_3, OUTPUT);
digitalWrite(PIN_AMP_0, 1);
digitalWrite(PIN_AMP_1, 1);
digitalWrite(PIN_AMP_2, 1);
digitalWrite(PIN_AMP_3, 1);
AudioMemory(60);
}
void loop() {
// put your main code here, to run repeatedly:
}
The MQS is not configured. No patch cable connected, nothing.
But I can hear the input signal on the headphone. This is not what I want because I need to do some audio processing before outputting the signal to the headphones..
What I found out is that the the transfer from the input to the MQS is not done by DMA.
Even if I disable DMA transfer (comment out all related code), the effect is still there.
At the end of the method begin() of the Spi input class I added the following lines:
Code:
I2S1_RCSR = 0;
I2S1_RCR2 |= I2S_RCR2_BCP; //polarity bit clock: rising edge
// set word width to 16 bit
uint16_t ww = 15;
I2S1_RCR4 &= ~I2S_RCR4_SYWD(31); // as soon as I comment these two lines
I2S1_RCR4 |= I2S_RCR4_SYWD(ww); // the effect diappears
I2S1_RCR5 = I2S_RCR5_WNW(ww) | I2S_RCR5_W0W(ww) | I2S_RCR5_FBT(ww);
I2S1_RCSR = I2S_RCSR_RE | I2S_RCSR_BCE | I2S_RCSR_FRDE | I2S_RCSR_FR;
As soon I comment out the lines handling I2S1_RCR4, the effect disappears. There must be some kind of internal
hardware connection between I2S1 I am using to read the ADC and I2S3 which is used for MQS.
Does anybody here has an advice or an idea how to fix this?
I appreciate any advice or reply, I'm lost with this issue at the moment.
In the attachment I added the full code of the modified input class.
Best
Christian