cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 F429 Discovery ADC DMA example very slow

bobert
Associate III
Posted on November 02, 2015 at 05:44

Hi,

I have an STM32F429I-DISCOVERY board and loaded up the example from the STM32Cube package. The example project directory in question isSTM32Cube_FW_F4_V1.9.0\Projects\STM32F429I-Discovery\Examples\ADC\ADC_RegularConversion_DMA This sets up 3 cycle sampling, 12 bit continuous conversion, with a callback upon DMA completion. In the callback, instead of turning on the LED I set it to toggle so I could easily scope it.

void
HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* AdcHandle)
{
/* Turn LED3 on: Transfer process is correct */
BSP_LED_On(LED3);
}
To
void
HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* AdcHandle)
{
/* Toggle LED line for scope */
BSP_LED_Toggle(LED3);
}

I'm generally getting right around 400KHz, or 800K samples per second, 0.8Msps instead of the 2.4Msps as the readme.txt claims: In this example, the system clock is 144MHz, APB2 = 72MHz and ADC clock = APB2/2.Since ADC3 clock is 36 MHz and sampling time is set to 3 cycles, the conversion time to 12bit data is 12 cycles so the total conversion time is (12+3)/36= 0.41us(2.4Msps). Any ideas what I'm doing wrong? I didn't change anything from the example other than that one line, perhaps there is a configuration issue with that demonstration? Thanks, Robert #adc-f429-disocvery-cube-example
1 REPLY 1
bobert
Associate III
Posted on November 02, 2015 at 07:43

I suspect this is related to the latency of the DMA system transferring single readings in this demo. I'll have to figure out if I am actually doing it right, but when I increased the ADC value variable to an array of 4, and requested a length of 4 instead of one:

HAL_ADC_Start_DMA(&AdcHandle, (uint32_t*)&uhADCxConvertedValue, 4);

That got my toggle line to 300KHz (600Ksps * 4) = 2.4Msps When I adjusted it to a length of 8:

HAL_ADC_Start_DMA(&AdcHandle, (uint32_t*)&uhADCxConvertedValue, 8);

That took the toggle line down to 150KHz (300Ksps * 😎 = 2.4Msps The speeds are now making sense and lining up. I don't have the DMA stuff working right (skipping slots), but that is not directly related to my original issue. If this all makes sense then perhaps the answer is to change the README for this demo project to not claim it will produce 2.4Msps out the gate.