2024-08-22 04:44 AM - last edited on 2024-08-22 04:57 AM by Andrew Neil
Hi, I’m new to the stm32mp15 series and I’ve been trying to convert code over from a previous microcontroller (stm32f429i-disc1) onto my new MPU. I try to read an input voltage value by running the HAL_ADC_GetValue driver but when I run live expressions to read the variable for my adc value, it is just maxed out at whatever I set the resolution to be (i.e., ADC1 resolution is 12 bits so the value is stuck at 4095). I use STM32CubeMX right now, I enabled continuous conversions but I get stuck at this 4095 value every time I debug and run. Any help or suggestions?
2024-08-22 04:51 AM
To add more info, I am connecting through input channel 1, single-ended mode. I have a wire hooked up to ANA0 and the breadboard and the voltage signal in series with it.
2024-08-22 04:53 AM
It sounds like you're encountering an issue with your ADC configuration on the STM32MP15 series MPU. Here are some steps and considerations to help you troubleshoot and resolve the issue:
Ensure that the ADC is correctly initialized in your code. Typically, this involves:
Verify that your ADC read code is correctly implemented. The HAL_ADC_GetValue() function should be used after starting the ADC conversion. Here’s an example of how you might do this:
Use the debugger to:
Try applying a different known voltage to the ADC input to see if the value changes. This can help determine if the issue is with the ADC configuration or the input signal.
Refer to the STM32MP15 series reference manual and datasheet for any MPU-specific details or differences in ADC handling compared to the STM32F429 microcontroller. The ADC peripheral might have different configurations or requirements on the STM32MP15.
If the issue persists, consider reaching out to the STM32 community forums or STMicroelectronics support for further assistance. They might have encountered similar issues and can provide additional insights.
By systematically checking each of these aspects, you should be able to identify and resolve the issue with your ADC configuration.
2024-08-22 07:05 AM
So I have ADC1 initialized here:
/* Initialize all configured peripherals */
MX_GPIO_Init();
T
hen below here is my ADC1 interrupt handler:
void ADC1_IRQHandler(void)
{
/* USER CODE BEGIN ADC1_IRQn 0 */
// Check if end of conversion flag for the analog voltage has been set
adc1_value = HAL_ADC_GetValue(&hadc1);
latest_pressure = Pressure_Calc(adc1_value);
/* USER CODE END ADC1_IRQn 0 */
HAL_ADC_IRQHandler(&hadc1);
/* USER CODE BEGIN ADC1_IRQn 1 */
/* USER CODE END ADC1_IRQn 1 */
}
With all this being said, I continue to get stuck at the value of 4095 in the case of a 12-bit resolution and I am converting this ADC value into a voltage. I have also tried a 16-bit resolution and get stuck at 65,535. while changing the 4096.0f value to 65,535.0f
(
// Calculate voltage from adc input
result.voltage = (float)adc1_value * (3.3f / 4096.0f);)
which also reads incorrect, all while using a scope to ensure the voltage reading from the component is correct which it is. My only problem now lies in reading it correctly on the MPU.