cancel
Showing results for 
Search instead for 
Did you mean: 

Problem: recovering ADC value

titouancurt
Associate II

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.

4 REPLIES 4

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?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
TDK
Guru

Use DMA to convert many ADC values into a circular buffer. Slow down sampling rate to something manageable and realistic for a microphone.

If you feel a post has answered your question, please click "Accept as Solution".

Yes, we thought about doing it afterwards, but for the moment we just wanted to test to see if the adc did indeed retrieve values in debug mode, and it didn't, so we didn't want to go any further if the basics didn't work.

I don't think I can connect an external potentiometer, it's the stevalmksbox1v1