Hi! I hope you are well. I have gotten the following example to work well on the nrf9160dk from Nordic, and am struggling to get it to work on the feather:

https://github.com/zephyrproject-rtos/zephyr/blob/main/samples/drivers/audio/dmic/prj.conf

I did update the overlay file to specify pin 3 as data in, since pin 30 is connected to the accelerometer.

/*
 * Copyright (c) 2020 Circuit Dojo LLC
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/ {
	chosen {
		nordic,pm-ext-flash = &w25q32jv;
	};
};

/* add digital mic  */
&pinctrl {
	pdm0_default_alt: pdm0_default_alt {
		group1 {
			psels = <NRF_PSEL(PDM_CLK, 0, 31)>, 
				    <NRF_PSEL(PDM_DIN, 0, 3)>; 
		};
	};

};

dmic_dev: &pdm0 {
	status = "okay";
	pinctrl-0 = <&pdm0_default_alt>;
	pinctrl-names = "default";
	clock-source = "PCLK32M_HFXO";
};

Since I only have one PDM (not PCM) mic connected, I removed the code specifying the second mic (lines 121 to 132), but otherwise the code is unchanged.

When I run the example it boots, configs the mic correctly (I believe), then enters the loop to read data where it seems to reads some data, start to print it through LOG_INF, then crash and reboot.

Connecting..
Connected to /dev/cu.usbserial-110!
*** Booting Zephyr OS build v3.3.99-ncs1-2 ***
[00:00:00.256,866] <inf> main: DMIC sample
[00:00:00.261,413] <inf> main: PCM output rate: 16000, channels: 1
[00:00:00.268,096] <inf> dmic_nrfx_pdm: PDM clock frequency: 1280000, actual PCM rate: 16000
*** Booting Zephyr OS build v3.3.99-ncs1-2 ***0x20012708 of 3200 bytes
[00:00:00.256,866] <inf> main: DMIC sample
[00:00:00.261,413] <inf> main: PCM output rate: 16000, channels: 1
[00:00:00.268,066] <inf> dmic_nrfx_pdm: PDM clock frequency: 1280000, actual PCM rate: 16000
*** Booting Zephyr OS build v3.3.99-ncs1-2 ***0x20012708 of 3200 bytes
[00:00:00.256,896] <inf> main: DMIC sample
[00:00:00.261,474] <inf> main: PCM output rate: 16000, channels: 1
[00:00:00.268,127] <inf> dmic_nrfx_pdm: PDM clock frequency: 1280000, actual PCM rate: 16000
*** Booting Zephyr OS build v3.3.99-ncs1-2 ***0x20012708 of 3200 bytes
[00:00:00.256,896] <inf> main: DMIC sample
[00:00:00.261,444] <inf> main: PCM output rate: 16000, channels: 1
[00:00:00.268,127] <inf> dmic_nrfx_pdm: PDM clock frequency: 1280000, actual PCM rate: 16000
*** Booting Zephyr OS build v3.3.99-ncs1-2 ***0x20012708 of 3200 bytes

I have tried a number of different pins, a range of values for CONFIG_MAIN_STACK_SIZE in proj.conf and can’t get anything to work.

It’s mystifying since I am using code that worked on the nordic dev kit, so I’m loath to make large changes.

Thank you!
Jason

CONFIG_DEBUG=y
CONFIG_RESET_ON_FATAL_ERROR=n
CONFIG_LOG_MODE_IMMEDIATE=y

Try these guys so you can see the output. As your intuition is leading you, it’s likely either a memory size issue, heap size issue or a driver issue.

Thanks for the debug help. Error was:

k_mem_slab_free(&mem_slab, buffer);
should be
k_mem_slab_free(&mem_slab, &buffer);

this pointer stuff I def don’t have a good intuition for yet!

14 days later

Well, I’m no longer getting errors, but I wrote some code to upload the file to a web server and I can see now that the file does not have actual audio data in it. Are pins 31 and 30 reserved for do they conflict somehow with digital mic using easyDMA? Here’s the current device file:

/ {
	chosen {
		nordic,pm-ext-flash = &w25q32jv;
	};
};

&pinctrl {
	/* add digital mic  */
	pdm0_default_alt: pdm0_default_alt {
		group1 {
			psels = <NRF_PSEL(PDM_CLK, 0, 31)>, 
				    <NRF_PSEL(PDM_DIN, 0, 30)>; 
		};
	};

	/* amp */
	 i2s0_default_alt: i2s0_default_alt {
		group1 {
			psels = <NRF_PSEL(I2S_SCK_M, 0, 19)>,  		// bclk?
					<NRF_PSEL(I2S_LRCK_M, 0, 21)>,     	// LRC
					<NRF_PSEL(I2S_SDOUT, 0, 22)>;      	// DIN
		};
	};
};

dmic_dev: &pdm0 {
	status = "okay";
	pinctrl-0 = <&pdm0_default_alt>;
	pinctrl-names = "default";
	clock-source = "PCLK32M_HFXO";
};

i2s_rxtx: &i2s0 {
	status = "okay";

	pinctrl-0 = <&i2s0_default_alt>;
	pinctrl-names = "default";
};

Thank you!
Jason

Hey Jason

P0.30 AKA D3 is also connected to INT1 on the accelerometer. Either you should use another pin or cut JMP1 which is on the bottom of the board:

5 days later

that worked! I tried that input on a bunch of other pins, but I couldn’t get it to work. I’m curious why that might be- I thought pins on the nrf9160 were pretty much re-assignable.

Thanks so much for your help!

Terms and Conditions | Privacy Policy