Pmod MIC3: MEMS Microphone with Nicla Sense

Hi,

I have a Nicla Sense, and Pmod MIC3 microphone. I am very new to SPI. I am sure the pin connections are correct. So, there should be a problem with my code. I keep getting zeros as an output. What is the issue with the code?

#define CS 6 // Assignment of the CS pin
 
#include <SPI.h> // call library
 
void setup() {
   Serial.begin(9600); // initialization of serial communication
   SPI.begin(); // initialization of SPI port
   SPI.beginTransaction(SPISettings(14000000, MSBFIRST, SPI_MODE0));
   pinMode(CS, OUTPUT);
}
 
void loop() {
   Serial.println(MIC3_getSound());  //display the measurements with the help of the serial plotter
}
 
int MIC3_getSound(void) {
   digitalWrite(CS, LOW);  //activate chip select
   int sound = SPI.transfer(0) | (SPI.transfer(0) << 8); //reconstruct 12-bit data
   digitalWrite(CS, HIGH); //deactivate chip select
   return sound;
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.