- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I playing with RX UART DMA based on CE224406 – PSoC 4 UART.
I want to have two 8 bytes RX buffers, which would be filled by DMA with data read by UART.
First thing i changed is data elements in transfer for both rx descriptors 0 and 1.
And everything works fine, after 8 keystrokes i got entered text back on my serial terminal. But it's done using the flag called txBufferIdx which points to currently used RX buffer. It's good, but when you skip one reading, everything would be out of sync.
So I try something like this
for(;;)
{
/* Wait for complete transfer and check if it comes from RX DMA */
if(0u == (UART_RX_DMA_CHANNEL_MASK ^ CyDmaGetInterruptSourceMasked()))
{
/* Clears the rxDMA interrupt source */
CyDmaClearInterruptSource(UART_RX_DMA_CHANNEL_MASK);
// detect which descriptor should be used
volatile uint32(descriptor0Stat) = UART_RX_DMA_GetDescriptorStatus(DESCR0);
volatile uint32(descriptor1Stat) = UART_RX_DMA_GetDescriptorStatus(DESCR1);
// it shoule be done to get data
if ( (descriptor0Stat & CYDMA_RESPONSE ) == CYDMA_DONE )
{
/* Points transmit DMA to buffer which contains received data and enables transfer */
UART_TX_DMA_SetSrcAddress(DESCR0, uartRxBuffer0);
UART_TX_DMA_ValidateDescriptor(DESCR0);
UART_TX_DMA_ChEnable();
}else
{
// maybe another one is done
if ( (descriptor1Stat & CYDMA_RESPONSE ) == CYDMA_DONE )
{
/* Points transmit DMA to buffer which contains received data and enables transfer */
UART_TX_DMA_SetSrcAddress(DESCR0, uartRxBuffer1);
UART_TX_DMA_ValidateDescriptor(DESCR0);
UART_TX_DMA_ChEnable();
}
}
}
}
I want to take decision which buffer should be send back based on DMA descriptors status' but after two first transfers the status got by UART_RX_DMA_GetDescriptorStatus is always 0x80010000 for both buffers.
What do i wrong?
Maybe another idea how to get info which is most recently filled buffer?
Thank you in advance
Kris
Solved! Go to Solution.
- Labels:
-
PSoC 4 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
qczek,
Do you really need DMA to receive UART messages? DMA is useful for streaming application, but for manual input it is rarely necessary. Please check these two examples of using PSoC4 UART to receive messages from terminal:
Sending String data through Uart and Receiving String Data through Uart
UART string reception garbage value
Projects attached.
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
qczek,
Do you really need DMA to receive UART messages? DMA is useful for streaming application, but for manual input it is rarely necessary. Please check these two examples of using PSoC4 UART to receive messages from terminal:
Sending String data through Uart and Receiving String Data through Uart
UART string reception garbage value
Projects attached.
/odissey1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
No i don't need DMA for 🙂
But it would be used to process not manually typed chars, but MAVLINK data stream. I use terminal only to find out how it works. I came from stm32 world and have no experience with PSOC DMA peripherals, and it's much easer to debug low data stream then real data.
Kris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OK, I found the function to get nextDescriptor and it works 🙂
volatile uint32 nextDescriptor = UART_RX_DMA_GetNextDescriptor();
if (nextDescriptor == DESCR1)
{
// so DESCR0 is just filled with the data :)
/* Points transmit DMA to buffer which contains received data and enables transfer */
UART_TX_DMA_SetSrcAddress(DESCR0, uartRxBuffer0);
UART_TX_DMA_ValidateDescriptor(DESCR0);
UART_TX_DMA_ChEnable();
}else
{
/* Points transmit DMA to buffer which contains received data and enables transfer */
UART_TX_DMA_SetSrcAddress(DESCR0, uartRxBuffer1);
UART_TX_DMA_ValidateDescriptor(DESCR0);
UART_TX_DMA_ChEnable();
}
But another question, how to get partially filled descriptor, when timeout occurs ?
I mean, that data stream stops, but we need to get data which are already in the buffer?
Kris