cancel
Showing results for 
Search instead for 
Did you mean: 

How to use ADC sensor with Ping Pong Application

AHakk.1
Associate III

Hello everyone, I am trying to read adc value from microphone. I am using FFT to get 100 Hz to 2 kHz or more to detect tone. In my project, I can use dma for get adc value and then I use DSP CMSIS. I can do this with my new workspace (with out anything only ADC-DMA) but when I try to implement this on Ping Pong Application I am struggling. I am beginner of stm32 and I can't find any video or blog about adding ADC sensor on stm32wl. 

As I say, I did all of things but I can't add ADC pooling or ADC DMA method on Ping Pong Application. I try to add adc_if.c, adc_if.h, sys_app.c,sys_app.h but I couldn't manage it.

I found adc.c and I configure it for Pool method, I only made continous cov mode enable.

hadc.Init.ContinuousConvMode = ENABLE;

and other files (adc.c etc.) I try to add these (I am using IN0 of ADC. So it is ADC_CHANNEL_0:

static uint32_t ADC_ReadMicData(uint32_t channel)
{
 uint32_t ADCxConvertedValues = 0;
 ADC_ChannelConfTypeDef sConfig = {0};
 MX_ADC_Init();
 /* Configure Regular Channel */
 sConfig.Channel = ADC_CHANNEL_0;
 sConfig.Rank = ADC_REGULAR_RANK_1;
 sConfig.SamplingTime = ADC_SAMPLINGTIME_COMMON_1;
 if (HAL_ADC_Start(&hadc) != HAL_OK)
 {
  /* Start Error */
  Error_Handler();
 }
 /** Wait for end of conversion */
 HAL_ADC_PollForConversion(&hadc, HAL_MAX_DELAY);
 /** Wait for end of conversion */
 ADCxConvertedValues = HAL_ADC_GetValue(&hadc);
 return ADCxConvertedValues;
 /* USER CODE BEGIN ADC_ReadChannels_2 */
 /* USER CODE END ADC_ReadChannels_2 */
 
}

I add my I2C sensor on my own but I couldn't find ADC for my Microphone.

Can you share me the way of adding any ADC sensor for Ping Pong Application ? or at least if there is any video or something, can you share with me please?

1 ACCEPTED SOLUTION

Accepted Solutions
IIRHO.1
ST Employee

Hello @AHakk.1​ and welcome to ST Community

I advice you to take a look at the demonstration LocalNetwork_Sensor that you can find in the STM32Cube_FW_WL_V1.3.0 . This demonstration is based on the Ping Pong application , It implements Sensor data sending (based on the Internal Temperature Sensor and VBat information ) to the demo concentrator ( you can also find it in the same firmware version) . both Temperature sensor and Vbat are using ADC protocol in communication .

Hope this is helpful .

If this is what you need , I suggest you to mention this answer as best answer so that the information will be defused.

Issam

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
IIRHO.1
ST Employee

Hello @AHakk.1​ and welcome to ST Community

I advice you to take a look at the demonstration LocalNetwork_Sensor that you can find in the STM32Cube_FW_WL_V1.3.0 . This demonstration is based on the Ping Pong application , It implements Sensor data sending (based on the Internal Temperature Sensor and VBat information ) to the demo concentrator ( you can also find it in the same firmware version) . both Temperature sensor and Vbat are using ADC protocol in communication .

Hope this is helpful .

If this is what you need , I suggest you to mention this answer as best answer so that the information will be defused.

Issam

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

AHakk.1
Associate III

Hello thanks for the reply. I already try these but I couldn't manage it. I look at it and I try to add ADC_ReadMicData function as in example.

adc_if.c and adc_if.h and sys.c and sys.h. I couldn't manage it.

I add in adc_if.c

uint32_t SYS_GetMicData(void)
{
  uint32_t measuredData = 0;
  measuredData= ADC_ReadChannels(ADC_CHANNEL_0);
  return measuredData ;
}

I add in adc_if.h

 uint32_t SYS_GetMicData(void);
 

but when I call SYS_GetMicData() in subghz_phy_app.c nothing return

so I add sys_app.c

uint16_t GetMicData(void)
{
  uint16_t measuredData = 0;
  measuredData= GetMicData();
  return measuredData ;
}

and I add sys_app.h

uint16_t GetMicData(void);

 and nothing return.

AHakk.1
Associate III

I found the problem, turns out I can't use the ADC_CHANNEL_0 in ping pong Application (I try to see in cubemxide pin configuration IN0 is pink). I don't know why but I change it ADC_CHANNEL_3 and now everything is working good.