UART with Circular DMA mode polling - NDTR gives wrong (full) value on wrap in circular buffer
Hello,
I'm experimenting with DMA, following a lot of examples. I'm reading DMA counter to determine if there are any new bytes received in circular buffer.
I use CubeIDE on STM32f779. I have following code :
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
uint16_t i, pos, start=0, length, length_all=0;
static uint16_t old_pos = 1;
// uint16_t currCNDTR = __HAL_DMA_GET_COUNTER(huart->hdmarx);
uint16_t currCNDTR;
currCNDTR = (uint16_t)huart->hdmarx->Instance->NDTR;
...It works ok until circular buffer wraps - in this case I have to assemble received message from two parts. But the problem is that currCNDTR (have tried several different options, but no go...) returns value of circular buffer size and therefore I have only 1 part, since NDTR should be different that buffer size (only if received bytes align with buffer size, but this is not the case).
It is interesting that reading from NDTR register inside debugging session I get "normal" value. There must be something wrong with a way how I read that register...
Any advice ?
Thanks in advance.
