1 2 Previous Next 28 Replies Latest reply on Mar 31, 2020 12:15 AM by lopo_1264666

    DMA watermark

    lopo_1264666

      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

        • 1. Re: DMA watermark
          JayakrishnaT_76

          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

          • 2. Re: DMA watermark
            lopo_1264666

            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);

            • 3. Re: DMA watermark
              JayakrishnaT_76

              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

              • 4. Re: DMA watermark
                lopo_1264666

                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.

                • 5. Re: DMA watermark
                  JayakrishnaT_76

                  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

                  • 6. Re: DMA watermark
                    lopo_1264666

                     

                     

                    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

                    • 7. Re: DMA watermark
                      JayakrishnaT_76

                      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

                      • 8. Re: DMA watermark
                        lopo_1264666

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

                        • 9. Re: DMA watermark
                          JayakrishnaT_76

                          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

                          • 10. Re: DMA watermark
                            lopo_1264666

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

                            • 11. Re: DMA watermark
                              JayakrishnaT_76

                              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

                              • 12. Re: DMA watermark
                                lopo_1264666

                                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[i] 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[i]);

                                                                 if (FileBuffer[i] != CorrectValue)

                                                                 {

                                                                        MissedSamples = FileBuffer[i] - CorrectValue;

                                                                        Value = FileBuffer[i];

                                                                        FilePtr = &FileBuffer[i];

                                                                        TotalMissedSamples += MissedSamples;

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

                                                                        CorrectValue = FileBuffer[i];            // Fixup for next sample

                                                                 }

                                                           }

                                                    }

                                • 13. Re: DMA watermark
                                  JayakrishnaT_76

                                  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[i]. 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[i] 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[i] 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[i] 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.

                                   

                                   

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

                                   

                                  Best Regards,

                                  Jayakrishna

                                  • 14. Re: DMA watermark
                                    lopo_1264666

                                    Attached is the snapshot. The counter count is incrementing.

                                    1 2 Previous Next