I want to setup the AD converter at 8KHz rate (for voice sampling). I know how to do it with timer interrupt. However I want to set it up directly using DMA.. Operation clock is at 144Mhz (and should be there)--> ADC clock is APB2/2=36Mhz Now using ADC_SMPR1 I can add 12+480 cycles which is not enough. Is there any clever way to set the ADC clock down to 8Khz?
Asked
Active
Viewed 277 times
1 Answers
1
In order to use DMA and ADC, you don't reduce the speed of Core or DMA. Mentioned clocks don't affect to sample rate. Sample rate must be set up by timer! But you shouldn't use timer interrupt! Use the following scheme:
- Setup timer on 8KHZ, I suppose you have it but don't enable interrypt!
- Set the event to start ADC conversion, for example:
hadc.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T3_TRGO;
Confiture timer to master mode by
HAL_TIMEx_MasterConfigSynchronization
function, example:TIM_MasterConfigTypeDef master_config = { .MasterOutputTrigger = TIM_TRGO_UPDATE, .MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE }; HAL_TIMEx_MasterConfigSynchronization(&hAudioInTim3, &master_config);
Run ADC:
HAL_ADC_Start_DMA(&hadc, buffer, size);
- Wait for
HAL_ADC_ConvCpltCallback
event and then process your data.

denis krasutski
- 618
- 4
- 9