Data transfer from U to P port

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
poas_4520791
Level 4
Level 4
First like received

Hi,

I'm using Fx3 and i have created 3 DMA channels-USB to CPU,CPU to P port,P port to USB.In the first DMA channel whatever the callback function i'm calling  in that i'm able to get the data.But in the CPU to P Port DMA channel i'm not able to receive the data that i got in first DMA channel.

Can any one help me out to do this.

Best Regards,

Aswini

0 Likes
1 Solution

Hello Aswini,

I went through the project and I found that you have combined BulkSrcSink and SlaveFifo examples.

The BulkSrcSink project preloads the DMA buffers associated with the MANUAL OUT channel and then commits them to the USB Side. When the buffer is committed and is read by the Host, you receive the CONS_EVENT from the USB Side.

In your project, I saw that the PROD_EVENT occurs fine. This is because PROD_EVENT is set when the Producer socket has filled a DMA buffer associated with the channel. So, when the USB socket fills the buffer with data, PROD_EVENT will occur. Also, in the DMA callback, i found that you are committing the buffer. This will pass the buffer to the CPU Socket.

You do not receive the CONS_EVENT because you are not sending any data from the CPU_Socket to the P Port. The CONS_EVENT will occur only when a buffer is sent out by the Consumer Socket. The buffer is not sent from CPU to the Consumer_Socket in the project, so it will not reach the P-Port and the device connected to the P Port cannot read data from it. Due to this, you will not get Cons_Event.

Also, the MANUAL In and MANUAL OUT channels are used only when you have to send data from any block in FX3 to the CPU or from CPU to any other block. If you want to have data transfer between two blocks within FX3 and want CPU intervention in between, please use a MANUAL channel with one block as Producer and another block as Consumer. If you want any modifications on the buffer received from Producer, you can do it in the DMA Callback due to PROD_EVENT and then Commit it to the consumer inside the DMA Callback itself.

You still can use the data path as U port->CPU and CPU->P Port. In this case, when the PROD_EVENT occurs for the first channel (U port->CPU), you need to copy the buffer into another buffer and commit it to the channel CPU->P Port. I have tried this and it works fine. But you will have a compromise on throughput.

So, we recommend that you make use of a single DMA channel between U Port and P Port in MANUAL Mode and add the required modifications to the buffer in the DMA callback.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna

View solution in original post

0 Likes
35 Replies
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello Aswini,

Please Answer my following questions:

1.Please let me know what is the application?

2.Why do you want 3 DMA buffers?

3.According to my understanding, you send some data from U port to CPU. You need to do some modifications to the buffer obtained and send it from CPU to P port. Am i correct with this or is there any difference?

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

Yeah,i sent some data from U port to  CPU,but in CPU to P port DMA channel i have declared one callback function in that i should receive data but i'm not getting there.May i know the reason for this?

Best Regards,

Aswini

0 Likes

Hello,

Please send me a snapshot of the DMA channel configuration for CPU to P port and U port to CPU.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

Here is the snapshot of DMA channel configuration,21.PNG

Regards,

Aswini

0 Likes

Hello,

I find that in the DMA channel between CPU Socket and P Port Socket, the callback is triggered only when the CY_U3P_DMA_CB_CONS_EVENT occurs. This means that it will occur only when the data send out by the CPU is consumed by the P Port, the callback function will be invoked. Please check whether you have connected a device to the P Port and whether it is getting data or not.

Please let me know your application.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

The callback is not triggered because the data isn't sending to P port. I just gave consumer socket as P port and is there any other way to check whether the device is connected to P port or not.

Can you please  let me know.

Regards,

Aswini

0 Likes

Hello,

Can you please share your project.

Also please let me know what do you wish to do by creating a channel between U port to CPU and between CPU to P port. This can help me debug the issue quickly.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

By using  U port to CPU and CPU to P port DMA channels and  callback functions i should able to transfer data to P port.

currently i'm using Microsoft visual studio 2017 through this software i'm trying to check the output and with 1st DMA channel (U port to CPU )everything is fine.Now i should get the data in the 2nd(CPU to P port) dma channel call back function.

kindly let me know the solution for this.

Regards,

Aswini

0 Likes

Hello,

I understand your final aim is to get a data transferred from U port to P port. You can do it directly by creating a DMA Manual channel between USB Socket and P Port Socket. In this case, whenever you receive a buffer from the Host(PC), a DMA callback can be triggered. In the DMA call back function, you can perform the required operations on the buffer and then commit the buffer to P Port. Please let me know whether this is what you want.

Best regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

Yeah,that's  what my application.If i use only  2 dma channels i.e., from USB to P port and P port to USB what will be the end points.Currently i'm using 3 endpoints i.e., 2 IN and 1 OUT.Now i should use only 1 IN and 1 OUT endpoint right?

The other question is in the callback function i should create a buffer and in that buffer i should able to  get the data.

If anything wrong in the above lines kindly let me know.

Regards,

Aswini

0 Likes

Hello Aswini,

Yes, when you use 2 DMA channels, one should be IN endpoint which is used by the HOST to read data from FX3 through U port. The other should be OUT endpoint which is used by the host to write to the U port. For the transfer between U port and P Port, you can create a DMA channel with the following configuration:

    dmaCfg.size  = DMA_BUF_SIZE* size;

    dmaCfg.count = CY_FX_SLFIFO_DMA_BUF_COUNT_U_2_P;

    dmaCfg.prodSckId = CY_FX_PRODUCER_USB_SOCKET;

    dmaCfg.consSckId = CY_FX_CONSUMER_PPORT_SOCKET;

    dmaCfg.dmaMode = CY_U3P_DMA_MODE_BYTE;

    /* Enabling the callback for produce event. */

    dmaCfg.notification = CY_U3P_DMA_CB_PROD_EVENT;

    dmaCfg.cb = CyFxSlFifoUtoPDmaCallback;

    dmaCfg.prodHeader = 0;

    dmaCfg.prodFooter = 0;

    dmaCfg.consHeader = 0;

    dmaCfg.prodAvailCount = 0;

    apiRetStatus = CyU3PDmaChannelCreate (&glChHandleSlFifoUtoP, CY_U3P_DMA_TYPE_MANUAL, &dmaCfg);

    if (apiRetStatus != CY_U3P_SUCCESS)

    {

        CyU3PDebugPrint (4, "CyU3PDmaChannelCreate failed, Error code = %d\n", apiRetStatus);

        CyFxAppErrorHandler(apiRetStatus);

    }

This creates a DMA Manual Channel between U Port and P Port. The Buffer size will be DMA_BUF_SIZE* size and there will be CY_FX_SLFIFO_DMA_BUF_COUNT_U_2_P number of such buffers. When the U Port fill one of such buffer, you will get a prod event. This will call the callback function CyFxSlFifoUtoPDmaCallback. Inside the callback function you can modify the received buffer as required in your application. Then you can commit the modified buffer to P Port.

We have an Application Note AN65974 which talks about the Slave FIFO interface using FX3. There is an attached project with this Application Note. In that project, we have configured 2 DMA channels one from P Port to U Port and other from U Port to P Port. Please refer to the project in the application note to find out how the DMA channels are created and how the buffers are committed upon receiving the PROD Events. The link to the application note is given below:

https://www.cypress.com/documentation/application-notes/an65974-designing-ez-usb-fx3-slave-fifo-inte...

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

I tried the code that is there in the (AN65974)  above link.but In visual studio i got the issue as shown belowvs.PNG

Regards,

Aswini

0 Likes

Hello,

Please let me know why you are using visual studio?

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

I  have to select a file in visual studio through that only i can able to get data to U port and CPU ,so i'm using this.

why can't i use 2 DMA channels U port to CPU and CPU to P port and what may be the reason for not receiving data in CPU to P port DMA channel.

Regards,

Aswini

0 Likes

Hello,

According to my understanding, your application is to move data from U Port to P Port. For this, the most easiest and straightforward way is to create a DMA channel between U port and P port. If you want to have CPU intervention in between U port and P port, then you can create a MANUAL DMA channel between U Port and P Port. This is equivalent to creating 2 DMA channels, i.e, one between U port and CPU and other between CPU and P Port. Further, creating two DMA channels will reduce the throughput.

Did you try testing the Slave FIFO design with Control Center Application? Please try testing it. I found that there is no error. You can also transfer file using the control center application to U Port. Once it fills the DMA buffers, it will be committed to the P Port.

Also, can you please let me know what is the device which you are planning to connect in the P Port?

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

I'm using FX3 device and i tried the slave fifo design with control center,but now i should  get data in the callback function which i have called in dma channel(CPU to P port).

Regards,

Aswini

0 Likes

Hello,

Please let me know which device is reading data from P Port. The cons event will not occur unless the device connected to P Port completely reads the data from the Buffer. This is the reason why you are not getting DMA call backs.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

can you please check this firmware once.

On Thu, Nov 21, 2019 at 4:31 PM JayakrishnaT_76 <

0 Likes

Hello Aswini,

Sure I can check the firmware. Can you please send me the complete project for a better understanding.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

Can you check the above firmware and kindly let me know whether there is any issue in the firmware.

Regards,

Aswini

0 Likes

Hello Aswini,

I went through the project and I found that you have combined BulkSrcSink and SlaveFifo examples.

The BulkSrcSink project preloads the DMA buffers associated with the MANUAL OUT channel and then commits them to the USB Side. When the buffer is committed and is read by the Host, you receive the CONS_EVENT from the USB Side.

In your project, I saw that the PROD_EVENT occurs fine. This is because PROD_EVENT is set when the Producer socket has filled a DMA buffer associated with the channel. So, when the USB socket fills the buffer with data, PROD_EVENT will occur. Also, in the DMA callback, i found that you are committing the buffer. This will pass the buffer to the CPU Socket.

You do not receive the CONS_EVENT because you are not sending any data from the CPU_Socket to the P Port. The CONS_EVENT will occur only when a buffer is sent out by the Consumer Socket. The buffer is not sent from CPU to the Consumer_Socket in the project, so it will not reach the P-Port and the device connected to the P Port cannot read data from it. Due to this, you will not get Cons_Event.

Also, the MANUAL In and MANUAL OUT channels are used only when you have to send data from any block in FX3 to the CPU or from CPU to any other block. If you want to have data transfer between two blocks within FX3 and want CPU intervention in between, please use a MANUAL channel with one block as Producer and another block as Consumer. If you want any modifications on the buffer received from Producer, you can do it in the DMA Callback due to PROD_EVENT and then Commit it to the consumer inside the DMA Callback itself.

You still can use the data path as U port->CPU and CPU->P Port. In this case, when the PROD_EVENT occurs for the first channel (U port->CPU), you need to copy the buffer into another buffer and commit it to the channel CPU->P Port. I have tried this and it works fine. But you will have a compromise on throughput.

So, we recommend that you make use of a single DMA channel between U Port and P Port in MANUAL Mode and add the required modifications to the buffer in the DMA callback.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

Can you explain the sentence "You do not receive the CONS_EVENT because you are not sending any data from the CPU_Socket to the P Port. The CONS_EVENT will occur only when a buffer is sent out by the Consumer Socket".

How can i know whether  data is transfering  from CPU socket  to P port or not?

I just created a buffer in the CPU to P port channel callback function,i thought i should get data into that buffer from CPU.Kindly let me know if i'm thinking wrong.

Regards,

Aswini

0 Likes

Hello,

For transferring data from CPU to P Port, you need to call the CyU3PDmaMultiChannelCommitBuffer() API. This API contains 3 parameters.

The first one is the Handle for the channel. This identifies the channel. The second one is the size of buffer that is to be committed and the last one is the status of the buffer being committed.

>>I just created a buffer in the CPU to P port channel callback function,i thought i should get data into the buffer from CPU.Kindly let me know if i'm thinking wrong.

In this project, CPU receives data from the U Port. This data is stored inside DMA buffers allocated for the channel between U port and CPU. The DMA buffers allocated for the channel between CPU and P Port are different. So if you need to send the data received from the first channel, you need to copy the contents of the buffer from first channel to the second channel and then commit it. This happens when you are using 2 DMA channels.

If you are using a single channel between U port and P Port with CPU intervention (i.e MANUAL channel between U Port and P Port), then when the U Port fills a buffer, the CPU is signalled. This is called as PROD_EVENT. The CPU can add modifications to the buffer and then commit it to the P Port. Your assumption is right for this type of DMA channel.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

You said by using 2 DMA channels between USB and P port i have to compromise on throughput .So I modified the firmware,now i'm using one DMA channel  i.e., USB to P port  and i'm using two endpoints 1 IN and 1 OUT,as shown below.

dma ch.PNG

If i change the DMA configuation,then in visual studio i'm getting "object reference not set to an instance of an object".

What might be the issue?

Kindly let me know how to solve this issue.

Regards,

Aswini

0 Likes

Hello,

Please check the debug prints and let me know whether any APIs are failing or not.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

I have checked the debug prints,everywhere in debug prints i'm getting like"no debug info".

Regards,

Aswini

0 Likes

Hello Aswini,

I understand that as there is no Debug Information, the code is working fine. Please test the project by making use of Control Center Application and let  me know the results.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

This may be a silly question,but i want to know why this has happend.In firmware now i'm using only 2  endpoints  but in control center,i'm getting the 3 end point (the one which  i have removed is also getting now)as shown  below.

ep.PNG

Can you please let me know the problem.

Regards,

Aswini

0 Likes

Hello,

Please check the function CyFxSlFifoApplnStart. Inside that you will see the API CyU3PSetEpConfig. This API is used to enable and set the properties for a specified endpoint. Just remove the endpoint that you dont want to use in the application.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

Yeah,before itself i have commented the things that are related to the 3 rd endpoint.

epcfg.PNG

But still in control center it's showing  3 endpoints.

Regards,

Aswini

0 Likes

Hello Aswini,

Please modify the descriptors to remove the 3rd endpoint from the control center application.

1.You need to comment out Endpoint Descriptor and companion descriptor for the endpoint that you do not want.

2.Once this is done, in the interface descriptor, change the number of endpoints to 2.

3.Change the "Length of this descriptor and all sub descriptors" field of the configuration descriptor accordingly.

Once the above steps are done, you can see the endpoint removed from control center.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Hello,

1.You need to comment out Endpoint Descriptor and companion descriptor for the endpoint that you do not want.

2.Once this is done, in the interface descriptor, change the number of endpoints to 2.

These things i have changed.

3.Change the "Length of this descriptor and all sub descriptors" field of the configuration descriptor accordingly.

I don't know how to change these  values .If you don't mind please let me know about this.

Regards,

Aswini

0 Likes

Hello,

Please add the descriptor size of Configuration descriptor type (in Configuration Descriptor), Descriptor size(in Interface Descriptor), Descriptor size (in Endpoint descriptor for producer EP), Descriptor size(in Super speed endpoint companion descriptor for producer EP), Descriptor size(in Endpoint descriptor for consumer 1 EP) and Descriptor size(in Super speed endpoint companion descriptor for consumer 1 EP) in your firmware. Then replace the field Length of this descriptor and all sub descriptors in the Configuration Descriptor with the result.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

I have added all the descriptor sizes and replaced that value in the place of  Length of this descriptor and all sub descriptors in the Configuration Descriptor.But i'm getting the same problem.

Can you please check the file attached below.

Regards,

Aswini

0 Likes

Hello,

Please send the complete project.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes