2017-03-13 08:13 AM
Board: STM32F767 Nucleo-144.
I use DMA to transfer results sampling from ADC at 1MHz to SRAM, but the data size is quite large which is 240k samples (480kbytes). However, a single DMA transfer (calling HAL_ADC_Start_DMA) only supports a data size of 65535, which is far below my requirement. And the ADC data transfer must be continuous, so I think starting a new DMA immediately may cause data loss? Is there anyway to do this?
Thank you.
2017-03-13 09:31 AM
You can split the data buffer in half using HT/TC interrupts to manage the non-active half, while remaining in continuous/circular mode. There should also be a double-buffering mechanism, which would allow you advance the blocks of memory being written too.
Even copying from a HT/TC managed buffer, I don't see that you'd need to suffer data loss.
2017-03-13 12:37 PM
Mark: Thanks for asking this question. I have exactly the same requirement coming up next week. Keep us updated on your progress and solution, if possible. Garry.
2017-03-13 03:34 PM
Hi,
Thank you for the hint, and I just find the double buffering mode library in stm32f7xx_hal_dma_ex.c, and I can use function HAL_DMAEx_ChangeMemory to change the memory address of one of the buffer after that buffer completes its transfer. However, I am still not sure about something. Could you answer my following questions?
a) For the function: HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength)
Double buffering mode is actually in circular mode, so what does datalength refer to? The buffer size? One single buffer or total size of two buffers?
b) If I want to change the memory address, is there any function I can call to know the transfer completion of one buffer? I only saw there is an enum type define as HAL_DMA_LevelCompleteTypeDef, but I did not see any function can return it.
c) How do I stop DMA when it reaches the amount of samples I want? Since double buffering is actually in circular mode, so I guess it will not stop only if I program it to?
Thank you.