2020-07-01 03:22 AM
Dear ST-community,
in my project I am trying to sample with 4 timer-triggered ADCs simultaneously, what works quite well. Afterwards I am transmitting the data via USB to the PC. As long as I store the data in a buffer and transmit it after the measurement, everything works fine. The Problem arises if the data is transmitted immediatly after the sampling, so if I want to stream the data to the host. If I do this in debug-mode, I receive about 100-400 samples, than the measurement stops. In normal-mode the measurement often doesn't even start. The debugger stops than before the while-loop where I wait for the ADC-Callback to be called.
I think it must be something to do with the USB-Interface since without the transmitting function the measurement doesn't stop. Before USB I used Uart where the TX-Cplt-Callback could be used, but now there is no such possibility.
Does anybody know what the problem is and how to solve this?
Thank you a lot in advance!
Best regards
2020-07-01 05:52 AM
How are you sampling and storing data? Is the ADC overrunning?
What does it mean when the measurements "stops"? Where in your code is it waiting?
2020-07-01 06:05 AM
The sampled data is stored in the DMA. And after one sample all four ADCS are stoped in the ADC-Callback.
The code stops than before the while-loop where I am waiting for the ADC-running-flag to be cleared. This means at some point the ADC-Callbacks aren't called anymore. Can anyone imagine what USB has to do with that?
It stops before this code:
while(measurement_status) {
}
The callback looks like this:
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *AdcHandle)
{
ADC_HandleTypeDef** adc_p = get_adc();
HAL_HRTIM_SimpleBaseStop(get_adc_timer(), HRTIM_TIMERINDEX_MASTER);
HAL_ADCEx_MultiModeStop_DMA(adc_p[0]);
HAL_ADCEx_MultiModeStop_DMA(adc_p[2]);
HAL_ADC_Stop_DMA(adc_p[1]);
HAL_ADC_Stop_DMA(adc_p[3]);
measurement_status = 0;
gpio_set_output(get_red_led(), 0);
}
Really appreciate your help