UART with DMA and IT on STM32F446
Hi everybody,
On my project, my µC receives data from a rapsberry pi on a serial bus.
For another project, I've used this method : https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx/blob/main/projects/usart_rx_idle_line_irq_F4/Src/main.c to receive data with unknown length, it was working very well.
So, i'd like to use the same thing, but I have something that I don't understand.
For my test, Raspberry in sending the following frame every 10s ("DATA RASPBERRY"). My buffer has 64 bytes.
The following line gives me the position of cursor :
pos = ARRAY_LEN(buffer_rx_dma_rs1) - __HAL_DMA_GET_COUNTER(huart->hdmarx);So, the first time, it gives me 14, the second time 28 and the third time 32 (instead of 42), but 32 is the half of 64.
When I take a look on the values, ARRAY_LEN(buffer_rx_dma_rs1) = 64 and __HAL_DMA_GET_COUNTER(huart->hdmarx) = 22, but pos = 32, how is it possible that the substract operation is false ?
