2014-10-12 09:31 AM
Hello everyone,
I am trying to port my software to HAL drivers and came across a problem with use of circular buffer. I use it on the RX of UART to continuously receive data. It works as it should on the Standard Peripheral Drivers, but I can't find my way around the new driversto implement the same function. In HAL drivers there is an option to chose the circular mode inDMA_mode ofDMA_HandleTypeDef. However I have no idea how to pass the address and size of a memory space where I want DMA to write my received data. I am also not sure how to initiate the transmission and how to get the current index inside the memory space? In old version I used the following code to initialize the DMA:
serialPortDMAInitStructure.DMA_PeripheralBaseAddr = USART_DR_ADDRESS;
serialPortDMAInitStructure.DMA_MemoryBaseAddr = (uint32_t)serialPortRxBuffer;
serialPortDMAInitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
serialPortDMAInitStructure.DMA_BufferSize = (uint32_t)USART_MAX_RX_BUFFER_LENGTH;
serialPortDMAInitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
serialPortDMAInitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
serialPortDMAInitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
serialPortDMAInitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
serialPortDMAInitStructure.DMA_Mode = DMA_Mode_Circular;
serialPortDMAInitStructure.DMA_Priority = DMA_Priority_VeryHigh;
DMA_Init(USART_RX_DMA_CHANNEL, &serialPortDMAInitStructure);
Also to get the current memory index I was using:
1.
DMA_GetCurrDataCounter(USART_RX_DMA_CHANNEL)
Of course I already checked out the examples, but unfortunately ST seems to miss out this use scenario.
I will appreciate any help.
Kind regards,
krprzemo
#uart #hal #stm32
2015-01-27 08:38 PM