2020-01-25 07:55 AM
hi hope have good day
i need to buffer data for save on every 1ms
for serial and spi i use dma to receive data
for example hal_uart_receviveDMA on this function must set buffer size ...
i test one example :
50Hz send to mcu data each time 1000 and 1001 and 1002... to full load data and baud 921600
1khz buffering(hal_uart_rec_dma) in 2000 length variable.
but i have some problem
in first time on the dma interrupt 1000 was ok second form 1000 to 2000 data add and 1 data lost and lost increase every 2 time buffer full
how can i find how many data receive for copy on other buffer and how can i receive without lost
thanks
2020-01-25 08:36 AM
For high data rate, use circular DMA.
JW
2020-01-25 08:52 AM
Here is a pretty nice tutorial: https://stm32f4-discovery.net/2017/07/stm32-tutorial-efficiently-receive-uart-data-using-dma/
2020-01-30 07:27 AM
thanks for reply
i use circular DMA and it work just for test board that is f1 not H7
now in H7 its a few complex
i do this change but i cant see any data in Buffer
ALIGN_32BYTES (uint8_t U1RxBuff[1000]);
ALIGN_32BYTES (uint8_t U2RxBuff[1000]);
ALIGN_32BYTES (uint8_t U3RxBuff[1000]);
ALIGN_32BYTES (uint8_t U4RxBuff[1000]);
ALIGN_32BYTES (uint8_t U5RxBuff[1000]);
int main(void)
{
SCB_EnableICache();
SCB_EnableDCache();
//some thing
MX_GPIO_Init();
MX_DMA_Init();
MX_UART4_Init();
MX_UART5_Init();
MX_UART7_Init();
MX_UART8_Init();
MX_USART1_UART_Init();
//some thing
SCB_InvalidateDCache_by_Addr ((uint32_t *) U1RxBuff, 1000);
SCB_InvalidateDCache_by_Addr ((uint32_t *) U2RxBuff, 1000);
SCB_InvalidateDCache_by_Addr ((uint32_t *) U3RxBuff, 1000);
SCB_InvalidateDCache_by_Addr ((uint32_t *) U4RxBuff, 1000);
SCB_InvalidateDCache_by_Addr ((uint32_t *) U5RxBuff, 1000);
HAL_UART_Receive_DMA(&huart1, U1RxBuff, 1000);
HAL_UART_Receive_DMA(&huart7, U2RxBuff, 1000);
HAL_UART_Receive_DMA(&huart8, U3RxBuff, 1000);
HAL_UART_Receive_DMA(&huart4, U4RxBuff, 1000);
HAL_UART_Receive_DMA(&huart5, U5RxBuff, 1000);
//some thing
}
static void MX_DMA_Init(void)
{
/* DMA controller clock enable */
__HAL_RCC_DMA1_CLK_ENABLE();
/* DMA interrupt init */
/* DMA1_Stream0_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn);
/* DMA1_Stream1_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn);
/* DMA1_Stream2_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream2_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream2_IRQn);
/* DMA1_Stream3_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn);
/* DMA1_Stream4_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream4_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream4_IRQn);
}
i cant see interrupt for dma in hal...it.c
data stream from source is continue send and i must save all of them
baud rate is 921600 and full load
2020-01-31 01:42 AM
i test lot of solution such as this link https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices?t=1580438940317
and template in cube mx folder for H7 uart dma but yet i cant receive correct data
i use cube ide
2020-01-31 01:59 AM
So, you first said:
> form 1000 to 2000 data add and 1 data lost
and then
> i do this change but i cant see any data in Buffer
So what is it, no data or 1 data point out of 1000 missing?
Read out and check the relevant DMA, DMAMUX and UART registers content.
JW
2020-01-31 02:29 AM
yes
i mention to that
at first i just use f1 ev borad for test (with your answer that work )
but at last in h7 borad I didn't get the previous answer(no data or 1 data)
2020-01-31 02:33 AM
my question is that why st cube mx example not correct receive uart ?
2020-01-31 02:39 AM
Well, I don't know and I don't care, I don't use CubeMX and I don't use 'H7.
The chip doesn't care about CubeMX either, it works out of its settings. That's why you should look at the registers.
JW
2020-02-01 12:39 AM
i have some change and now i can see data in buffer
but have new problem
in circular dma mode data continuously received but lot of data wrong
in normal mode i can just one time correct frame and stop receive data