2018-08-15 12:44 AM
Problem with ADC reading at 100 kHz via DMA.
MCU runs @ 48 MHz, ADC @ 14 MHz. Configured via CubeMX.
Trying to read one ADC channel (1.5 cycles), triggered by Timer 15 (100 kHz) using HAL.
Cannot reach 100 kHz (see pictures). Blue are DMA interrupts (half=rising, complete=falling edge), yellow is Timer 15 interrupt (toggle).
First step with this one line Timer15 ISR:
void TIM15_IRQHandler(void) {
HAL_GPIO_TogglePin (GPIOC, GPIO_PIN_8);
}
Rem.: 100 kHz ok.
Then add call to HAL_ADC_Start_DMA ()
void TIM15_IRQHandler(void){
HAL_GPIO_TogglePin (GPIOC, GPIO_PIN_8);
HAL_ADC_Start_DMA (&hadc, adc32_dma, 1);
}
Rem.: Timer frequency dropped to 56.2 kHz…
Rem.: DMA needs 4.4 µsec (incl. 1.6 µsec for DMA ISRs), not 1/2.6 µsec…
What goes wrong here?
2018-08-15 12:49 AM
2018-08-15 12:49 AM
2018-08-15 01:49 PM
You dont want to do this:
void TIM15_IRQHandler(void){
HAL_GPIO_TogglePin (GPIOC, GPIO_PIN_8);
HAL_ADC_Start_DMA (&hadc, adc32_dma, 1);
}
this is 100KHz of 5uSeconds delay you only have 10uS in 100KHz...
I run this line Once on startup, and never again:
MAIN:
ADC_RowCounter = 0; // gather 16 rows of data
Ave_ADC_ChannelCounter = 0;
ADC_ChannelsCounter = ADC_ChannelCount; // 15 ADC channels
HAL_ADC_Start_DMA(&hadc, (uint32_t *)ADC_DMABuffer, ADC_ChannelCount);
while(1){
...
2018-08-15 01:57 PM
>>What goes wrong here?
Decimate the interrupt loading, buffer 10 samples via DMA