IMXRT1024 eDMA Sequential Receive Operation to the Top of Receive Buffer

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

IMXRT1024 eDMA Sequential Receive Operation to the Top of Receive Buffer

1,674件の閲覧回数
Lukas_Frank
Senior Contributor I

Hi all,

I have the following scenario in my UART DMA communication.

 

Scenario : I know the max size of incoming packets and different size of packets are comming to my buffer. I just  want to seperate these packets and extract to use them from my buffer. For example I have the 120 buffer length. It can be 128,256 whatever I want and system constraints is permit. But the incoming data-sizes are like 60 bytes, 75 bytes, 90 bytes etc. (smaller than buffer size)

Lukas_Frank_2-1631002839755.png

 

Status : When I use LPUART_ReceiveEDMA and LPUART_SendEDMA,after once LPUART_ReceiveEDMA is called, system always writing datas to the end direction of buffer address in memory to turn back to Start Address. Incoming datas are continously coming to my receiver. New LPUART_ReceiveEDMA operation is calling after reaching at the end of buffer address in memory.

For example, I sent 60 bytes to my receiver port. Then, I sent 16bytes more. I just want LPUART_ReceiveEDMA write to receiveBuffer from the start address not after Dataword60. But it continues from Dataword61 to write 16bytes to address. Probably, it is the characteristic of memory usage of eDMA.

Lukas_Frank_5-1631003288383.png

I just want it doing this to the top of memory so reseting the pointer index to Start Address and then continue to receiving my datas, if it is possible by doing some modification. As seen in below:

Lukas_Frank_6-1631003294694.png

Could you help me please? How can I do that?

 

Thanks and Regards.

0 件の賞賛
返信
10 返答(返信)

1,622件の閲覧回数
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello

Hope you are well. I can help you with this.
It would be helpful if you share your DMA configuration.
If you want that the data transferred through the DMA is always written in the Start address of your buffer make sure that the DADDR matches with the start address.

If you have more questions do not hesitate to ask me.
Best regards,
Omar

0 件の賞賛
返信

1,596件の閲覧回数
Lukas_Frank
Senior Contributor I

Hi Dear @Omar_Anguiano,

Appreciate for your help. I hope you are well too. 

The only two thing that I changed in default SDK example(lpuart_edma_transfer) are buffer length of g_rxBuffer and sending method in while loop. I did not change any configuration parameters so they are defaults. Like below:

void EDMA_GetDefaultConfig(edma_config_t *config)
{
    assert(config != NULL);

    /* Initializes the configure structure to zero. */
    (void)memset(config, 0, sizeof(*config));

    config->enableRoundRobinArbitration = false;
    config->enableHaltOnError           = true;
    config->enableContinuousLinkMode    = false;
    config->enableDebugMode             = false;
}


This is my sending loop code:

uint8_t tempArray[sizeof(sendXfer.data)] = {0};
uint8_t iteratorInner;
uint64_t valuesInner;
while (1)
{

    if ((!rxOnGoing))
    {
        rxOnGoing = true;
        LPUART_ReceiveEDMA(DEMO_LPUART, &g_lpuartEdmaHandle, &receiveXfer);
    }

    if ((!txOnGoing))
    {
		//Purpose is just changing the sended value for better monitoring in memory.
		//So, what comes to receiveBuffer.			
		for(iteratorInner = 0; iteratorInner< sizeof(sendXfer.data); iteratorInner++)
		{
			valuesInner++;
			tempArray[iteratorInner] = valuesInner;
		}
		sendXfer.data = tempArray;
		sendXfer.dataSize = sizeof(tempArray);
		//Purpose is just changing the sended value for better monitoring in memory.
		//So, what comes to receiveBuffer.			
		
        txOnGoing = true;
        LPUART_SendEDMA(DEMO_LPUART, &g_lpuartEdmaHandle, &sendXfer);
    }

}


For the receive operation I am passing receiveXfer parameter to the LPUART_ReceiveEDMA function. So receive buffer is setting as destination address (DADDR) with EDMA_PrepareTransfer. DADDR is always setting as start address of my receive buffer. But system is using buffer like ringbuffer I think, so it continue from the last written adress.

So I exactly mean below. ( Stated in the figures that I published above answer )

1-) Buffer size is setted as 256 byte.

2-) I send to receiver 64 byte packet.

3-) g_rxBuffer includes this 64 byte on ram.

4-) After a time, I send to receiver 70 byte packet.

5-) Systems starts writing from the 64th index of g_rxBuffer in the ram.

6-) It goes on like this for a while until it reaches the end of 256 as new data comes in.

7-) Than, starting to write from start address again and so on.

Which type of other matching requirement is exist? I am not clear with your expression as . Please correct if I misunderstood with your expression. Does not DADDR matches with the start address in my example?

Thanks and Regards.

0 件の賞賛
返信

1,523件の閲覧回数
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Thank you for your patience.
I suggest you check the function EDMA_PrepareTransfer() to prepare the transfer.
In the buffer structure, you will be transferring data until the buffer is full and start from the beginning of the buffer. The ringbuffer example can be helpful, but instead of receiving the data in the buffer, you can send it to another memory location modifying the TCD.

If you have more questions do not hesitate to ask me.
Best regards,
Omar

0 件の賞賛
返信

1,506件の閲覧回数
Lukas_Frank
Senior Contributor I

Hi Dear @Omar_Anguiano,

 

I detaily examine the example code. But I am not fit how it can possible about what you say? I am aware about new data comes to the start address of g_rxBuffer when we call EXAMPLE_ReadingBuffer in the ring buffer eDMA SDK example. But there are missing and invalid cases too. For example;
BUFFER_SIZE:16

1-) send 4byte 

2-) receive all bytes with EXAMPLE_ReadingBuffer

3-) it writes from start of g_rxBuffer

4-) send 7byte

5-) receive all bytes with EXAMPLE_ReadingBuffer 

6-) it does not write from start of g_rxBuffer, it copies some of the datas indexes from the last content of g_rxBuffer to the top of g_rxBuffer. Then it copies new 7 data to the below.

7-) So if we send more data size than once before it does not start from top. But if we send equal or small data size than before it copies from start index.

 

What exactly do you mean with “but instead of receiving the data in the buffer, you can send it to another memory location modifying the TCD” ?

 

Is there anything should I do additional to the edma_rb_transfer SDK example? Should I modify and dedicate another TCD channel for my scenario?

 

Could you please share me example code ?

 

Thanks and Regards.

0 件の賞賛
返信

1,377件の閲覧回数
Lukas_Frank
Senior Contributor I

Hi Dear @Omar_Anguiano,

 

I am still waiting for your support. Can you help me please?

 

Best Regards.

0 件の賞賛
返信

1,471件の閲覧回数
Lukas_Frank
Senior Contributor I

Hi Dear @Omar_Anguiano ,

 

I appreciate you for giving your time to help me in really intensive time period of you. I am waiting for your feedbacks to my last answer. I think this post is really hot and can be benefical to the other member of the community. We can help others too, if we can handle and solve the issue.

 

Thanks and Regards.

0 件の賞賛
返信

1,556件の閲覧回数
Lukas_Frank
Senior Contributor I

Hi Dear @jeremyzhou 

Hi Dear @FelipeGarcia 

Hi Dear @danielchen 

Hi Dear @Alexis_A 

Hi Dear @kerryzhou 

 

Could you please help me about my topic and last answer? Thanks for your interests. I am really stucked.

 

Thanks and Regards.

 

0 件の賞賛
返信

1,577件の閲覧回数
Lukas_Frank
Senior Contributor I

Hi @Omar_Anguiano 

 

Could you help me please ? I am waiting for the solution.

 

Thanks and Regards.

0 件の賞賛
返信

1,618件の閲覧回数
Lukas_Frank
Senior Contributor I

error

0 件の賞賛
返信

1,644件の閲覧回数
Lukas_Frank
Senior Contributor I

Hi Dear @jeremyzhou,

 

I hope you are well. Sometimes system can miss the topic.

Could you help me about the above topic please? 

Thanks and Regards. 

0 件の賞賛
返信