I'm realizing UART-DMA with STM_HAL library and I want to know if message size is counted by hardware (counting clock ticks till line is idle for example) or by some program method(something like strlen). So if Size in
HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
is counted by hardware, I can send data in pure HEX format, but if it is calculated by something like strline, I may recieve problems if data is 0x00 and have to send data in ASCII.
I've tried to make some research in generated code in Keil but failed (maybe I didn't try hard enough) so maybe somebody can help me.
If you are using UART DMA, it is calculated by hardware.
If you check the call hierarchy of
HAL_UARTEx_RxEventCallbackusing your ide, you can see how the Size variable is calculated.The function is executed in the following flow.(Depending on the version of HAL Driver, it may be slightly different)
HAL_UART_IRQHandler()HAL_UARTEx_RxEventCallback(huart, (huart->RxXferSize - huart->RxXferCount))Therefore,
Sizevariable is calculated as(huart->RxXferSize - huart->RxXferCount)huart->RxXferSizeis a set value when initializing RX DMA.huart->RxXferCountis(huart->hdmarx)->Instance->NDTRNDTR is a value calculated by hardware as the size of the buffer remaining after DMA transfer data to memory!!