cancel
Showing results for 
Search instead for 
Did you mean: 

How to sense a 8Hz signal from the ADC3 pin(shared with mic) of SensorTile (STM32L476xx)?

Abhilash Iyer
Associate
Posted on August 20, 2017 at 01:57

I recently purchased a SensorTile  which has a STM32L476(JGY6) microcontroller inside it. It looks like that there are 3 ADC pins coming out of the board - ADC1, ADC2, and ADC3.  ADC1 & ADC2 are shared with I2C3 on which there is a temperature sensor. So, I am choosing the ADC3 channel to read my analog inputs coming at 8Hz. 

I have two questions: 

1. The ADC3 channel comes from the pad 3 (MIC_CLK) of MIC. Will this affect my sensitivity?  

2. This one is a basic one - Is there a C code example on how to listen to ADC channels from STM32L476? If the functions of the ADC getdata() is implemented, Can someone tell me where exactly is it? How to use it? 

      

I saw a stm32l476xx_nucleo.c  example in which they interface the joystick at the ADC 1 channel. But the code has two variables which I am not sure what they are: 

static ADC_HandleTypeDef hnucleo_Adc;

static ADC_ChannelConfTypeDef hnucleo_AdcChannelConfig; 

Here is the relevant parts of the code: 

* @brief ADC Interface pins

* used to detect motion of Joystick available on Adafruit 1.8' TFT shield

*/

&sharpdefine NUCLEO_ADCx ADC1

&sharpdefine NUCLEO_ADCx_CLK_ENABLE() __HAL_RCC_ADC_CLK_ENABLE()

&sharpdefine NUCLEO_ADCx_GPIO_PORT    GPIOB

&sharpdefine NUCLEO_ADCx_GPIO_  PIN       GPIO_PIN_0

&sharpdefine NUCLEO_ADCx_GPIO_CLK_ENABLE()    __HAL_RCC_GPIOB_CLK_ENABLE()

&sharpdefine NUCLEO_ADCx_GPIO_CLK_DISABLE()    __HAL_RCC_GPIOB_CLK_DISABLE()

/ ADC Private functions

&sharpifdef HAL_ADC_MODULE_ENABLED

static HAL_StatusTypeDef ADCx_Init(void);

static void ADCx_MspInit(ADC_HandleTypeDef *hadc);

&sharpendif /* HAL_ADC_MODULE_ENABLED */

Will I have to implement the ADCx_MSPInit() and ADC_Init()? And also where can I find the definitions of functions & variables of ADC in the following code? 

hnucleo_AdcChannelConfig.Channel = ADC_CHANNEL_15;                                 // What channel is 15? There are only 3 available channels right?

hnucleo_AdcChannelConfig.SamplingTime = ADC_SAMPLETIME_24CYCLES_5; // Definition?

hnucleo_AdcChannelConfig.Rank = 1;

hnucleo_AdcChannelConfig.SingleDiff = ADC_SINGLE_ENDED;

hnucleo_AdcChannelConfig.OffsetNumber = ADC_OFFSET_NONE;

It would be really great if you could provide some help. 

Thanks,

#drivers #stm32l476-adc #stm32mxcubehal #adc #hal
0 REPLIES 0