cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L151 ADC

Wyorin
Associate

I am working with the above device. I have created an .IOC file and auto-generated code. I can see the GPIO configuration for the simple I/O, but I do not see any pin configuration for the ADC inputs that I have selected. I assume that I will have to add these to the MX_ADC_Init module.

I have attached the .IOC file that I have created.

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

They are generated in stm32l1xx_hal_msp.c file in HAL_ADC_MspInit():

 

    /**ADC GPIO Configuration
    PF6     ------> ADC_IN27
    PF7     ------> ADC_IN28
    PC1     ------> ADC_IN11
    PC2     ------> ADC_IN12
    PC3     ------> ADC_IN13
    PA0-WKUP1     ------> ADC_IN0
    PA1     ------> ADC_IN1
    */
    GPIO_InitStruct.Pin = VCC_12V_Pin|VCC_3V3_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = TEMPERATURE_Pin|TEMPA_Pin|TEMPB_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = ISENSE_3V3_Pin|ISENSE_12V_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 

Note that HAL_ADC_MspInit() is called by HAL_ADC_Init() which in turn called by MX_ADC_Init()

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

1 REPLY 1
SofLit
ST Employee

Hello,

They are generated in stm32l1xx_hal_msp.c file in HAL_ADC_MspInit():

 

    /**ADC GPIO Configuration
    PF6     ------> ADC_IN27
    PF7     ------> ADC_IN28
    PC1     ------> ADC_IN11
    PC2     ------> ADC_IN12
    PC3     ------> ADC_IN13
    PA0-WKUP1     ------> ADC_IN0
    PA1     ------> ADC_IN1
    */
    GPIO_InitStruct.Pin = VCC_12V_Pin|VCC_3V3_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = TEMPERATURE_Pin|TEMPA_Pin|TEMPB_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = ISENSE_3V3_Pin|ISENSE_12V_Pin;
    GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 

Note that HAL_ADC_MspInit() is called by HAL_ADC_Init() which in turn called by MX_ADC_Init()

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.