2024-03-11 08:35 AM
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.
Solved! Go to Solution.
2024-03-11 08:51 AM - edited 2024-03-11 08:54 AM
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()
2024-03-11 08:51 AM - edited 2024-03-11 08:54 AM
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()