ADC Value Distortion
Hello,
I have been experiencing a problem with the usage of the internal ADC on my STM32L476RG Nucleo64 development board. Unfortunately I have not been able to find similar problems online or in the forums.
I would like to use the highest possible sampling rate (5.33 MSps according to https://wiki.st.com/stm32mcu/wiki/Getting_started_with_ADC). However, this wiki article uses the clock divisor of 64x and sample time of 92.5 cycles.
For testing purposes, I am generating a 1Hz 3.3Vpp sine wave with an Agilent 33250A waveform generator and measuring the signal on the wire to the ADC pin with an oscilloscope. As sample rate increases, the signal is distorted immensely.

The signal at 64x clock divisor.

The signal at 8x clock divisor.

The signal at 1x clock divisor.
It seems odd to me that the ADC is strong enough to overpower a waveform generator.
I am using DMA sampling across five channels (though this signal is only on the first one) and writing into a 500x5 buffer.
void OptionReadAllRaw() {
eprints("Option 0: Read Raw Data From All Sensors\r\n");
OpMode = ReadAllRaw;
HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
HAL_ADC_Start_DMA(&hadc1, (uint32_t*) SensorData,
SENS_BUF_LEN * SENS_BUF_WID);
}void TickReadAllRaw() {
if (SensorDataLastProcessed != SensorDataFresh) {
uint16_t offset = SENS_BUF_LEN / 2 * SensorDataFresh;
SensorDataLastProcessed = SensorDataFresh;
char interm[100];
ClearString(sbuf);
for (int i = 0; i < SENS_BUF_LEN / 2; i++) {
sprintf(interm, "%i %i %i %i %i\r\n",
SensorData[i * SENS_BUF_WID + offset + 0],
SensorData[i * SENS_BUF_WID + offset + 1],
SensorData[i * SENS_BUF_WID + offset + 2],
SensorData[i * SENS_BUF_WID + offset + 3],
SensorData[i * SENS_BUF_WID + offset + 4]);
strcat(sbuf, interm);
eprints(sbuf);
}
}
HAL_Delay(200);
}
I am aware that this will not be sending all of the data; my main issue for now is that the data is bad.
The ConvCplt and ConvHalfCplt callbacks only flip a flag.





Could anyone explain what is happening, and how I can ensure that the ADC readings of values are accurate at the highest possible sample rates?
Please let me know if I can provide any more information on the setup.
Thanks in advance.
