DMA watermark

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

cross mob
lopo_1264666
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

I would like to know why DMA watermark in FX3 code does not tally with GPIF implementation for both GPIF_Example8 and GPIF_Example9 in "SuperSpeed Design Examples V1.2.1"?

GPIF_Example8

CyU3PGpifSocketConfigure(2, GPIF_PRODUCER_SOCKET, 8, CyFalse, 1);

POSTREAD012 RepeatCount = 2

GPIF_Example9

CyU3PGpifSocketConfigure(3, GPIF_CONSUMER_SOCKET, 7, CyFalse, 1);

POSTWRITE012 RepeatCount = 2

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

Hello,

Please refer to the Section General Formula for using Partial Flags in the following document in page 18.

https://www.cypress.com/file/136056/download

From CY_U3P_PIB_GPIF_BUS_CONFIG in SlaveFifoWrite.h, it can be understood that the Bus width is 32 bits for this project.

Consider the case of Example 9. This example configures FX3 as a master to write data to a CPLD from FX3's FIFO. Here, the watermark flag is configured to be 7. Therefore, applying the formula mentioned in the above link for write, we have number of data words that may be written after the clock edge at which the partial flag is sampled asserted will be 3. This is correct because once the partial flag is asserted, the DMA buffer will have only 3 data words and the state machine will switch to the state POSTWRITE012 and drive the last 3 data words.

Now, consider the case of example 8. This example configures FX3 as a master to read data from a CPLD into FX3's FIFO. Here, the watermark flag is configured to be 8. Therefore, applying the formula mentioned in the above link for read, we have number of data words available for reading after the clock edge at which the partial flag is sampled asserted will be 7. This seems to be a mistake as you will only have 3 words to be read when the partial flag is sampled asserted. These 3 words will be sampled in the state POSTREAD012. So, you can try changing the watermark value from 8 to 4 in example 8.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna

View solution in original post

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

Hello,

Please refer to the Section General Formula for using Partial Flags in the following document in page 18.

https://www.cypress.com/file/136056/download

From CY_U3P_PIB_GPIF_BUS_CONFIG in SlaveFifoWrite.h, it can be understood that the Bus width is 32 bits for this project.

Consider the case of Example 9. This example configures FX3 as a master to write data to a CPLD from FX3's FIFO. Here, the watermark flag is configured to be 7. Therefore, applying the formula mentioned in the above link for write, we have number of data words that may be written after the clock edge at which the partial flag is sampled asserted will be 3. This is correct because once the partial flag is asserted, the DMA buffer will have only 3 data words and the state machine will switch to the state POSTWRITE012 and drive the last 3 data words.

Now, consider the case of example 8. This example configures FX3 as a master to read data from a CPLD into FX3's FIFO. Here, the watermark flag is configured to be 8. Therefore, applying the formula mentioned in the above link for read, we have number of data words available for reading after the clock edge at which the partial flag is sampled asserted will be 7. This seems to be a mistake as you will only have 3 words to be read when the partial flag is sampled asserted. These 3 words will be sampled in the state POSTREAD012. So, you can try changing the watermark value from 8 to 4 in example 8.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Based on the information below, DMA watermark for GPIF_Example5 was set wrongly? When DMA1_Watermark goes high, CPLD moves to PAUSE state, waits for another DMA buffer to become available. I assumed the correct level should be 1.

Status = CyU3PGpifSocketConfigure(1, GPIF_CONSUMER_SOCKET, 3, CyFalse, 1);

0 Likes

Hello,

Please confirm that you are talking about GPIF_Example5 in your response 2. Also, did you change the watermark value for GPIF_Example 8?

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Yes, I did change the DMA watermark for GPIF_Example 8 and test the code for 30s. The outcome is the same as before where there is break in the counter sequence.

I checked other example (GPIF_Example5) to confirm if my understanding about your explanation is correct and found this discrepancy. That’s why I would like to clarify this too.

0 Likes

Hello,

I see that in the GPIF_Example5, FX3 tries to write data from FIFO to CPLD or CPLD tries to read data from FX3's FIFO. So, here you should consider FX3 writing data into the CPLD and use the formula for number of data words that can be written once the partial flag is asserted. Yes, the watermark value seems to be a mistake here also. It should be configured as 4.

Then, by applying the formula, the number of data words that may be written when the partial flag is asserted will be [4*(32/32) - 4] = 0.

Please let me know if you have any queries on this.

Best Regards,

Jayakrishna

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

GPIF_Example4: CPLDasFifoMaster, FX3 reads data from CPLD

DMA watermark = 4

GPIF_Example5: CPLDasFifoMaster, FX3 writes data to CPLD

DMA watermark = 4 and not 1?

GPIF_Example8: CPLDasFifoSlave, FX3 reads data from CPLD

DMA watermark = 1+3 = 4

GPIF_Example9: CPLDasFifoSlave, FX3 writes data from CPLD

DMA watermark = 4+3 = 7

0 Likes

Hello,

I apologise for making a mistake in my previous response. The watermark value need to be configured in the way as you said. FX3 writes data from FIFO to CPLD. So a Read from FIFO operation is taking place. So, we need to configure the watermark value to 1 in accordance to the formula for reading the words from the FIFO once watermark value is reached. This will give the watermark value as 1. Once again, I apologise for my mistake.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

The book mentioned that there should be no breaks in the counter sequence for GPIF_Example8 but I couldn’t get this result.

0 Likes

Hello,

Can you please elaborate on what exactly you meant by "break in the counter sequence". I understand that the data from the CPLD is incremental. So is it like it breaks at a particular count or is it like some data is missing in between the incremental data?

Best Regards,

Jayakrishna

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

I follow the steps outlined in the book and found out that the collected data is not monotonic.

0 Likes

Hello,

Please confirm that you had run the CollectData host Application with the time limit above 30s and then Hit START first before pressing the user button on explorer kit to start the transfer. Also, please confirm that you pressed the button to stop the transfer only once. That is the sequence should be:

1. Start the CollectData host application with time limit set above 30s.

2. Press the User Button on explorer kit to start the transfer.

3. Press the User button on explorer kit to stop the transfer.

Please do not press the user button again after this. Please try this and let me know if you are still facing errors.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

I followed your steps below to run the test. BTW, I didn’t press on the user button to stop the transfer since the UI has timeout. Next, I used CheckData.exe to analyze the CollectData.bin and it always showed -1. Then I opened the CheckData source codes and added in these 2 lines. I am surprised to find out that the values for CorrectValue and FileBuffer didn’t change at all (through the printf), please advise.

while (BytesRead)

{

Success = ReadFile(ReadFileHandle, FileBuffer, sizeof(FileBuffer), &BytesRead, 0);

for (i=0; i<BytesRead/4; i++)

{

if (FirstTime)

{

FirstTime = false;

CorrectValue = FileBuffer[0];

}

else CorrectValue++;

TotalSamples++;

printf("\nCorrectValue = %ld", CorrectValue);

printf("\nFileBufferValue = %ld", FileBuffer);

if (FileBuffer != CorrectValue)

{

MissedSamples = FileBuffer - CorrectValue;

Value = FileBuffer;

FilePtr = &FileBuffer;

TotalMissedSamples += MissedSamples;

printf("\nGap of %d at index %d", MissedSamples, TotalSamples);

CorrectValue = FileBuffer; // Fixup for next sample

}

}

}

0 Likes

Hello,

Please find my comments below:

1. As you know, CheckData Application is used to verify if the data transmitted is incremental or not. This is done by using the values of CorrectValue and FileBuffer. So, initially, the value of FileBuffer[0] is assigned to CorrectValue. From there, the value of CorrectValue is incremented. After incrementing, a comparison is done to check if CorrectValue and FileBuffer are the same or not. If they are the same, then it means that there is no break in data. Otherwise, there is some break and the break is reported by using the value of Gap. Once the Gap value is printed, the value of FileBuffer is assigned to CorrectValue again to understand if there are more breaks in the upcoming data samples.

2. From your prints, I understood that FileBuffer is 0 for all values of i. This means that the data transferred from CPLD is all 0s instead of incremental data. Please verify this by using control center application and performing a data IN operation. For doing this, open the drop down as shown below, then select Bulk in endpoint and hit Transfer Data - IN Button. You can see the transferred data. Check if you are getting an incremental data or if you are getting all 0s.

pastedImage_0.png

Please let me know the result after performing the test mentioned in step 2 of this response.

Best Regards,

Jayakrishna

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

Attached is the snapshot. The counter count is incrementing.

0 Likes

Hello,

Please share a snapshot of the CheckData.exe. Also, please let me know whether you are seeing the gap from index 2 or are you seeing it from a higher index value?

Best Regards,

Jayakrishna

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

The gap = -1 forever for GPIF_Example8 and CPLDasFifoSlave,

0 Likes

Hello,

From the snapshot, I find that the FileBuffer always have the same value for all values of i. Please share the CollectData.bin file so that I can understand things better.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

The file size is huge (~1GB data if I run the test for 3s). Do you have the hardware at your end to duplicate my problem?

0 Likes

Hello,

Please open the .bin file using Hex Editor and share a snippet of the same.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

Showing below is the result for GPIF_Example8_data. Not sure why before 0x100000, data is the same.

GPIF_Example8_data.png

0 Likes

Showing below is the result for "GpifToUsb.img". "CheckData.exe" showed "gap of -256" forever but hex editor showed the counter is incrementing except "0" is recorded twice.

GpifToUsb_data.png

0 Likes

Hello,

For GpiftoUsb.img, the result that Iam seeing is expected. This is because, this example project is made to count data from 0x00000000 to 0x000000FF. So, when the collected data is dropped into checkdata.exe, initially CorrectValue will  be 0 and will be same as FileBuffer[0]. Now, on next iteration, CorrectValue will be incremented and is checked with FileBuffer[1]. As the data in the buffer is monotonically increasing upto 0x000000FF, you will not see any gap upto that count. When the Correct value is 255(0x000000FF) and on next iteration of the loop, the CorrectValue gets incremented to 256(0x00000100). But the FileBuffer will be 0 as the firmware for GpiftoUsb.img is developed in such a way that once the count reaches 0x000000FF, it resets and counts again from 0x00000000. Due to this there occurs a mismatch between CorrectValue and FileBuffer[256] and hence a gap of 256 is seen. This is as expected.

Regarding your snapshot in response 21, I have some questions.

1. Did you get the same result when you used control center, that is repeated occurrence of 0xEFEFEFEFs?

2. Did you start collectdata.exe before you programmed the .img file to explorer kit?

3. Can you please try programming the device with the .img file for GPIF_Example8 and collect data multiple times using the collectdata.exe and check if you are seeing the same result everytime?

According to my understanding, this repeated occurrence of 0xEFEFEFEF gives you a gap of -1 again and again. So, we need to understand how and why this 0xEFEFEFEF is sampled by FX3.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

1. Did you get the same result when you used control center, that is repeated occurrence of 0xEFEFEFEFs?

I need to press the user button on the SS explorer board and at the same time clicked on the "Transfer Data-IN". Not sure if I am fast enough but I don't see this repeated hex in control center.

2. Did you start collectdata.exe before you programmed the .img file to explorer kit?

I followed these steps outlined in the book:

(a) Reprogram CPLD using "CPLDasFifoSlave.xsvf".

(b) Set all CPLD switched to "Open".

(c) Load and run "GPIF_Example8.img".

(d) Run "CollectData.exe" with time limit = 30s and click START.

(e) Press the user button on the SS explorer board.

3. Can you please try programming the device with the .img file for GPIF_Example8 and collect data multiple times using the collectdata.exe and check if you are seeing the same result everytime?

Yes, data is consistent.

0 Likes

Hello,

From your response to my question 3 in the last reply, I understand that always you are getting repeated 0xEFEFEFEFs before 0x100000. Please correct me if Iam wrong in this.

Also, please try the following and let me know the result:

1. Perform all the steps as mentioned in your last response except pressing the user button on explorer kit. Now, without pressing user button on explorer kit, hit the Transfer DATA-IN button in control center and let me know if you are getting 0xEFEFEFEF.

2. If you are getting 0xEFEFEFEF now in control center, please follow all the steps as mentioned in your previous response without starting the "CollectData.exe". First press the user button on explorer kit and then you can start the "CollectData.exe".

Please try both of these tests and let me know the result.

Best Regards,

Jayakrishna

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

Step 1: Cannot read data at all without pression user button.

0 Likes

Hello,

Thanks for trying out my suggestion. Can you try the following and let me know if you are still seeing 0xEFEFEFEFs?

(a) Reprogram CPLD using "CPLDasFifoSlave.xsvf".

(b) Set all CPLD switched to "Open".

(c) Load and run "GPIF_Example8.img".

(d) Press the user button on the SS explorer board.

(e) Run "CollectData.exe" with time limit = 30s and click START.

Please try this and let me know the result.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes

The result is the same as before where I got 0xEFEFEFEF at the beginning. Let’s wait for the hardware to reach your end.

0 Likes
lock attach
Attachments are accessible only for community members.

Hello,

Please do the following and share a snapshot of the checkdata.exe.

1. Remove the CPLD board from the superspeed explorer kit.

2. Program the explorer kit with the attached .img file.

3. Open collectdata.exe and generate the .bin file by running the application for 5-10s.

4. Click, drag and drop the generated .bin file into checkdata.exe.

Note: This is not the firmware that corresponds to Gpif_Example8 in the book. It is just an example to test and understand what exactly is happening. Also, you might see gaps. Please do this and share the snapshot.

Best Regards,

Jayakrishna

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

Hello,

Please try collecting the data with the host application attached in this response.

In the original source code, we found that the buffers are preloaded with EFs initially. Also, the entire buffer was stored into the .bin file irrespective of the data received by the host. The new application is modified so that only the data collected by the host will be written into the .bin file. No extra data will be written. Please try testing this and let us know the results.

Best Regards,

Jayakrishna

Best Regards,
Jayakrishna
0 Likes