INMP441 may be producing data in the wrong channel

Status
Not open for further replies.

AlaaM

New member
Hi

I wrongly posted on "Project Guidance" and I didn't find a way to delete the post there... So I opened a new one here.

I'm working on the microphone INMP441 on mono-output mode. I see in the datasheet that if the L/R PIN (4) is on low then the left channel is activated, and otherwise the right channel. In my case it's on low so I expect to have values only in the left channel, which according to the datasheet is in the first 2 bytes of every 4-byte sample. Problem is looks like this is not consistent. For example here's a snapshot from a buffer I get after DMA sampling:
data[0]: 23296
data[1]: 0
data[2]: 0
data[3]: 13
data[4]: 13824
data[5]: 0
data[6]: 0
data[7]: 12
data[8]: 62208
data[9]: 0
data[10]: 0
data[11]: 11
data[12]: 53504
data[13]: 0
data[14]: 0
data[15]: 11
data[16]: 27904
data[17]: 0

I would expect to have relevant data in the entries (0,1), (4,5), (8,9), (12,13), (16,17) . But looks like there's a shift or something in the data (for example I see non-zero values in data[3], which shouldn't be the case.

Any help is appreciated.

Thanks
 
does the L/R PIN High (right channel) give all starting with data[1],data[2] etc.?
 
Hi

I wrongly posted on "Project Guidance" and I didn't find a way to delete the post there... So I opened a new one here.

I flagged the post to admin (press triangle on lower left corner) It is usually for signalling/removing Spam, so I 'misused' this feature (Robin to advice)
 
does the L/R PIN High (right channel) give all starting with data[1],data[2] etc.?

Ok I just tried that. Still not consistent.

One message (good):
data[0]: 0
data[1]: 0
data[2]: 65526
data[3]: 37376
data[4]: 0
data[5]: 0
data[6]: 65525
data[7]: 23808
data[8]: 0
data[9]: 0
data[10]: 65523
data[11]: 28416
data[12]: 0
data[13]: 0

Another message (bad):
data[0]: 0
data[1]: 65521
data[2]: 61184
data[3]: 0
data[4]: 0
data[5]: 65524
data[6]: 1536
data[7]: 0
data[8]: 0
data[9]: 65523
data[10]: 15360
data[11]: 0
data[12]: 0
data[13]: 65525
data[14]: 47872
 
Ok I just tried that. Still not consistent.

OK, now we are back to form rule. We need complete code you were using. Otherwise, the forum cannot advice.

If code is too long, remove all code not relevant to problem, but keep code still running.
usually by doing so, you will find the problem yourself, if not, someone of us may have may insight.
 
Code:

#define BUFF_SIZE 1024
static uint16_t i2s_buffer[BUFF_SIZE] = {0};
extern I2S_HandleTypeDef hi2s2;

void mic_start()
{
HAL_I2S_Receive_DMA(&hi2s2, (uint16_t*)(i2s_buffer), BUFF_SIZE/2);
}

void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
{
if(hi2s->Instance == hi2s2.Instance){
HAL_I2S_Receive_DMA(&hi2s2, (uint16_t*)(i2s_buffer), BUFF_SIZE/2); //I set BP here and watch i2s_buffer
}
}

int main()
{
//i2s initialize...
mic_start();
}

---------------------------------------------------------------------------------------------
Basically this is the code. I set a BP inside the callback and look at i2s_buffer.
I'm using cubemx for the HAL functions.

DMA Settings:
Peripheral data width: half word , memory data width: half word
Data and frame format: 24 Bits data on 32 Bits frame
Selected audio frequency: 16 KHz

Please tell me if I need to post anything else.

Thanks!
 
Code:

Code:
#define BUFF_SIZE 1024
static uint16_t i2s_buffer[BUFF_SIZE] = {0};
extern I2S_HandleTypeDef hi2s2;

void mic_start()
{
    HAL_I2S_Receive_DMA(&hi2s2, (uint16_t*)(i2s_buffer), BUFF_SIZE/2);
}

void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
{
	if(hi2s->Instance == hi2s2.Instance){
		HAL_I2S_Receive_DMA(&hi2s2, (uint16_t*)(i2s_buffer), BUFF_SIZE/2); //I set BP here and watch i2s_buffer
	}
}

int main()
{
	//i2s initialize...
	mic_start();
}
---------------------------------------------------------------------------------------------
Basically this is the code. I set a BP inside the callback and look at i2s_buffer.
I'm using cubemx for the HAL functions.

DMA Settings:
Peripheral data width: half word , memory data width: half word
Data and frame format: 24 Bits data on 32 Bits frame
Selected audio frequency: 16 KHz

Please tell me if I need to post anything else.

Thanks!

Interesting.
This application does not seem to use Teensy Core /audio functions. Are you even using a Teensy?
Anyhow, there may be some other forum user familiar with your programming environment. I'm unfortunately not. Sorry, cannot help further.
 
Oh I didn't know this is only Teensy support... I'm not using any audio functions because I just need to sample raw data and send it to a smartphone.
I just googled 'INMP441 forum' and found this website...
Thanks anyway!
 
Status
Not open for further replies.
Back
Top