DMA Buf ready and GPIF

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

cross mob
Ascs_4819156
Level 3
Level 3
10 replies posted 10 sign-ins 5 replies posted

Dear sir,

Now I am trying the develop a product with CYUSB3014, and I am reading 2 documents to help me understand it.

<<001-76074_EZ-USB_FX3_Technical_Reference_Manual.pdf>> and <<001-92220_AN75779_How_to_Implement_an_Image_Sensor_Interface_with_EZ-USB_FX3_in_a_USB_Video_Class_UVC_Framework.pdf>>

And I find a problem.

In the chapter 7.11 of Techincal reference manual, there is a flag named DMA_RDY_TH0. And DAM_RDY_TH1.

According to my understand, this flag is used to solve the GPIF's problem between data transfer and the DMA buffer switch in different thead. When the thread is swith to used a free DMA buffer, this flag is used to pause the data transfer.

So if the GPIF used 2 thread to receive the data, this flag should be used.

But in the AN75779, I did not find any information about this flag. So does it mean that there is a loss of data during the 2 thread switch in AN75779 example?

Thanks

Chad

0 Likes
1 Solution
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

Your understanding on the need for flag is correct. But, AN75779 makes use of a different approach to track if the buffers are full. This is done by making use of counters in the GPIF II designer tool. Two counters are used for the implementation. Both the counters are loaded with initial value of 0 and a limit which is calculated by using the following formula:

JayakrishnaT_76_0-1614220363082.png

In AN75779 state machine, LD_ADDR_COUNT and LD_DATA_COUNT are used for loading the counter. Please refer to the snapshot of a section of AN75779 state machine below:

JayakrishnaT_76_1-1614220578699.png

 

The sampling of data takes place in the states PUSH_DATA_SCK0 and PUSH_DATA_SCK1 in such a way that the state PUSH_DATA_SCK0 samples data into thread 0 and PUSH_DATA_SCK1 samples data into thread 1. The reason for using this approach is already documented in section 3.3 - Ping-Pong DMA buffers of the Application Note AN75779. 

Now, in the state PUSH_DATA_SCK0, three actions are performed. They are listed below:

1. IN_DATA - This samples data at each PCLK and stores into DMA buffers associated with socket 0 (which is mapped into thread 0).

2. COUNT_DATA- This increments the DATA count by 1 at each PCLK 

3. LD_ADDR_COUNT - This reloads the ADDR count.

When the COUNT_DATA reaches the limit which was used while loading the DATA counter, it indicates that a DMA buffer associated with socket 0 is full. Also, the transition equation DATA_CNT_HIT will be triggered and this makes the state machine to switch to PUSH_DATA_SCK1. In this state, the following actions are used:

1. IN_DATA - This samples data at each PCLK and stores into DMA buffers associated with socket 1 (which is mapped into thread 1).

2. COUNT_ADDR- This increments the ADDR count by 1 at each PCLK 

3. LD_DATA_COUNT - This reloads the DATA count.

When the COUNT_ADDR reaches the limit which was used while loading the ADDR counter it indicates that a DMA buffer associated with socket 1 is full. Also, the transition equation ADDR_CNT_HIT will be triggered and this makes the state machine to switch to PUSH_DATA_SCK0.

This is the working of AN75779 state machine in its most basic level. Other factors such as FV,LV are also considered for the development of the complete state machine. More details on the complete implementation is provided in Section 3.4 - Design Strategy and Section 3.5 - GPIF II state machine of the Application Note AN75779. Please have a look at it and let me know if you have any queries on it.

Best Regards,
Jayakrishna

View solution in original post

2 Replies
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hello,

Your understanding on the need for flag is correct. But, AN75779 makes use of a different approach to track if the buffers are full. This is done by making use of counters in the GPIF II designer tool. Two counters are used for the implementation. Both the counters are loaded with initial value of 0 and a limit which is calculated by using the following formula:

JayakrishnaT_76_0-1614220363082.png

In AN75779 state machine, LD_ADDR_COUNT and LD_DATA_COUNT are used for loading the counter. Please refer to the snapshot of a section of AN75779 state machine below:

JayakrishnaT_76_1-1614220578699.png

 

The sampling of data takes place in the states PUSH_DATA_SCK0 and PUSH_DATA_SCK1 in such a way that the state PUSH_DATA_SCK0 samples data into thread 0 and PUSH_DATA_SCK1 samples data into thread 1. The reason for using this approach is already documented in section 3.3 - Ping-Pong DMA buffers of the Application Note AN75779. 

Now, in the state PUSH_DATA_SCK0, three actions are performed. They are listed below:

1. IN_DATA - This samples data at each PCLK and stores into DMA buffers associated with socket 0 (which is mapped into thread 0).

2. COUNT_DATA- This increments the DATA count by 1 at each PCLK 

3. LD_ADDR_COUNT - This reloads the ADDR count.

When the COUNT_DATA reaches the limit which was used while loading the DATA counter, it indicates that a DMA buffer associated with socket 0 is full. Also, the transition equation DATA_CNT_HIT will be triggered and this makes the state machine to switch to PUSH_DATA_SCK1. In this state, the following actions are used:

1. IN_DATA - This samples data at each PCLK and stores into DMA buffers associated with socket 1 (which is mapped into thread 1).

2. COUNT_ADDR- This increments the ADDR count by 1 at each PCLK 

3. LD_DATA_COUNT - This reloads the DATA count.

When the COUNT_ADDR reaches the limit which was used while loading the ADDR counter it indicates that a DMA buffer associated with socket 1 is full. Also, the transition equation ADDR_CNT_HIT will be triggered and this makes the state machine to switch to PUSH_DATA_SCK0.

This is the working of AN75779 state machine in its most basic level. Other factors such as FV,LV are also considered for the development of the complete state machine. More details on the complete implementation is provided in Section 3.4 - Design Strategy and Section 3.5 - GPIF II state machine of the Application Note AN75779. Please have a look at it and let me know if you have any queries on it.

Best Regards,
Jayakrishna

Dear Jayakrishna,

Thanks for your answer.

Yes, I know how the GPIF works in AN75779.  And I understand now.

Thanks again.

Chad

0 Likes