cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
247 Views
Registered: ‎12-04-2019

Use mmap() to received finish signal from my FPGA GPIO with awful delay

Hello everyone, I'm a newbie of FPGA development

I'm using Redpitaya Stemlab 125-14 FPGA board(Zynq-7010)

I re-write a simple FPGA block design

This app received external trigger I gave and after 40000 triggers, "immediately" sending a finished signal to AXI GPIO IP & custom Bram Reader

and I used mmap() to receive the finished signal and start mmap the Bram data, and then enter the next loop.

But there is always a huge delay between my IP block send finished signal & my C program detects it.

The weirdest thing is that If I increase the frequency of external trigger, my C could detect more quickly even almost simultaneously!

my trigger is from SpinCore's PulseBlaster , so I can easily see when is the last trigger and finished timing and notice that there is a huge interval time

between finished timing & C received it.

That is how I discover the huge delay.

here is part of my C program, (*((uint32_t *)(cfg + 8))) is how I detect the finish signal from FPGA

 

  dat = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40000000);
  cfg = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x42000000);
while(l <= loop & measuring == 1)
      {
        time_begin = clock();
        if (measuring == 1 && (*((uint32_t *)(cfg + 8))) & 1 != 0) { /* here is the main delay I get !!! */

          /* transfer all samples */
          nsmpl = (1<<nsamples);
          printf("nsmpl = %d \n",nsmpl);

          for(j = 0; j < 1; ++j)
          {
            buffer[j] = (*((uint32_t *)(dat + 4*j)));
            printf("buffer = %d ,", buffer[j]);
          }

          /* resend configs */
          *((int32_t *)(cfg + 0)) = (STOP) + (timing<<8) + (nsamples<<16) + (naverages<<24);
          *((int32_t *)(cfg + 0)) ^= 1;

          time_spent = ((double)(clock() - time_begin)) / CLOCKS_PER_SEC; // measure time
          send(sock_client, buffer, 4*4*nsmpl, MSG_NOSIGNAL);
          printf("%d samples measured in %f s, l = %d\n", nsmpl, time_spent, l);
          l += 1;
          //measuring = 1;
        }
      }

And this is the simple view of my block design, the switch port is connected to the output finished signal

and the attachment is my general detail view of Block Diagram and C program

I don't know whether is the system clock cause this problem because of connecting to GPIO IP ?

system.jpg

 

Tags (2)
0 Kudos
0 Replies