I work with STM32F4Discovery board, generate code from Cube, SYSCLK is 168MHz, APB1 Timer Clock 42 MHz, TIM6 has prescaler 1000, and counts till 62. I make the following experiment.
Enable TIM6 interruption by
__HAL_TIM_ENABLE_IT(&htim6, TIM_IT_UPDATE);
HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
Start DAC_DMA in normal mode with 30-elements array.
Count how many timer interruptions happen
void TIM6_DAC_IRQHandler(void) {
HAL_TIM_IRQHandler(&htim6);
tim6Counter++;
}
Set breakpoint in this function:
void HAL_DAC_ConvCpltCallbackCh1(DAC_HandleTypeDef *hdac) {
conversionCounter++;
}
What I expect:
1) HAL_DAC_ConvCpltCallbackCh1 is called once (due to noncircular mode). It is true.
2) When it's called tim6Counter has to be equal 30, as length of DAC data buffer is 30. In experiment tim6Counter is 1.
3) After DAC is completed, set breakpoints to TIM6 handler, and to main while(1) loop. The problem is, that it hangs in TIM6 handler.
Questions:
1) DMA works even if TIM6 interruptions are not enabled. But if enabled, why it happens only once, instead of every DMA request?
2) Why it hangs in timer handler?
3) TIM6 SR register is not cleared, either by HAL macros, or by HAL_TIM_IRQHandler. I use eclipse with openOCD. Is it a problem of tools? Or due to hanging in handler?
The problem is, that timer still counts during debug pause. After switching timer to debug mode by
it works properly. Section 20.3.4 of reference manual was missed by me while reading.