A
A
Alexander Semykin2016-08-01 17:03:27
Microcontrollers
Alexander Semykin, 2016-08-01 17:03:27

How to properly set up DMA interrupts on STM32F4?

New tasks for STM32F4, and I have, accordingly, new questions. This time - to the HAL library and the logic of the DMA interrupts. I'm trying to organize a DMA ring buffer into which the ADC dumps information on interrupts from the timer. There are no problems with this part, it works perfectly.
But now I'm trying to raise the flags for processing the information buffer from the ADC using DMA interrupts. The first rises when half of the buffer is filled, the second - when the entire buffer is filled. It would seem that the code is elementary:

/* Функция обработки прерывания от DMA2 */
void DMA2_Stream0_IRQHandler(void) {
  HAL_DMA_StateTypeDef DMA_State;

  // Заполняем структуру состояния DMA и сбрасываем флаги
  HAL_DMA_IRQHandler(&hDma_MicAdc);

  // Как только заполнена первая половина буфера, поднимаем флаг обработки
  DMA_State = HAL_DMA_GetState(&hDma_MicAdc);
  if (DMA_State == HAL_DMA_STATE_READY_HALF_MEM0) {
    MicData_handle_flag = FIRST_HALF;
  } else if (DMA_State == HAL_DMA_STATE_READY_MEM0) {
    MicData_handle_flag = SECOND_HALF;
  }else {
    MicData_handle_flag = NONE;
  }
}

The problem is that the program, once entering the interrupt (on filling half of the DMA buffer), loops and enters it again and again. As if the interrupt flags are not reset, although I see the opposite in the code of the HAL_DMA_IRQHandler library function. What could be the reason?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Ocelot, 2016-08-03
@vagrantnotes

Half Transfer Interrupt twitches not once when half is full, but every time DMA writes to a buffer that is more than half full. Here is how to live with it: we.easyelectronics.ru/STM32/osobennosti-ispolzovan...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question