2025-03-13 4:11 AM - last edited on 2025-03-13 4:16 AM by Andrew Neil
I've been stuck for several days retrieving adc values from the mp23abs1 analog microphone on my stevalmksbox1v1. I just want to test to see if the adc values fluctuate according to the sound level where I am, but nothing moves. In debug mode in live expressions, I still have a fixed adc value between 4020 and 4024. My code in main is as follows:
uint16_t ADC_VAL = 0;
int count = 0;
HAL_ADC_Start(&hadc1);
while (1)
{
HAL_ADC_PollForConversion(&hadc1, 100);
ADC_VAL = HAL_ADC_GetValue(&hadc1);
HAL_Delay(500);
count ++;
}
I have attached the configuration of my ioc. The aim is to make a sound level meter, so to get the audio signal from the microphone and convert it into DB SPL. This is for a project in my engineering school. Thank you in advance for your help.
Code formatting applied - please see How to insert source code for future reference.
2025-03-13 4:23 AM
Welcome to the forum.
Please see How to write your question to maximize your chances to find a solution - we need more details!
Have you tried the ADC with just a steady input - eg, from a potentiometer?
2025-03-13 6:00 AM
Use DMA to convert many ADC values into a circular buffer. Slow down sampling rate to something manageable and realistic for a microphone.