Jump to content
  • 0

Working with the digital discovery board SDKs


ssm

Question

Hello everyone,

I am trying to use the digital discovery board to read a series of raw 32 bits coming through pins 0 to 31. There are many examples I looked at, but all of them uses 16 bit int for the sample. I need to read them as samples, each 32 bits. I tried using the waveforms and it worked nicely. It even gave me the option to read them as unsigned numbers in decimal format which is what I need.

any help is greatly appreciated,

Here is a segment of my code:

FDwfDigitalInInternalClockInfo(hdwf, &hzSys);

FDwfDigitalInDividerSet(hdwf, hzSys/2e5); // sampling at 200KHz

FDwfDigitalInSampleFormatSet(hdwf, 32); // so the size of the sample is 32 bits

FDwfDigitalInBufferSizeInfo(hdwf, &cSamples);

// default buffer size is set to maximum

rgwSamples = new unsigned int[cSamples]; // here is the problem, the type is 16 bits, so I am reading 16 bit signed (although declared unsigned)

// set trigger position to the middle

FDwfDigitalInTriggerPositionSet(hdwf, cSamples/2); // not sure about this, it was in one of the examples

// trigger on any pin transition

FDwfDigitalInTriggerSourceSet(hdwf, trigsrcDetectorDigitalIn);

FDwfDigitalInTriggerAutoTimeoutSet(hdwf, 10.0);

//FDwfDigitalInTriggerSet(hdwf, 0,0,0xFFFFFFFF,0xFFFFFFFF); // I tried this, it did not work

 FDwfDigitalInConfigure(hdwf, true, false);

// begin acquisition

FDwfDigitalInConfigure(hdwf, false, true); // start

do{

         if(!FDwfDigitalInStatus(hdwf, true, &sts)) return 0;

}while(sts != stsDone);

// get the samples

FDwfDigitalInStatusData(hdwf, rgwSamples, cSamples*sizeof(unsigned int)); // again the size of the sample here is 16 but this is the only thing the worked

 

thank you

Sam

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

thank you @attila for the reply,

it is taking that much time, but the problem is that when I feed it for example 7fffffff, I am reading it as 7fff only, so it is as if I read the upper 16 bits only, how can I read the whole 32 bits? 

ssm

Link to comment
Share on other sites

  • 0

Hi @ssm

If you specify 32bit samples you get 32bit samples. You are also using 32bit array, uint. How are you looking at the values ?

Here a 32bit walking 1 signal is connected to Digital Discovery DIN 0 to DIO 31 and captured like this:

image.png

#include <stdio.h>
#include <stdlib.h>

#ifdef WIN32
#include "dwf.h"
#elif __APPLE__
#include "/Library/Frameworks/dwf.framework/Headers/dwf.h"
#else
#include <digilent/waveforms/dwf.h>
#endif

int main(int carg, char** szarg) {
    HDWF hdwf;
    STS sts;
    double hzSys;
    int cSamples = 100000;
    unsigned int* rgdwSamples = new unsigned int[cSamples];
    char szError[512] = { 0 };

    if (!FDwfDeviceOpen(-1, &hdwf)) {
        FDwfGetLastErrorMsg(szError);
        printf("Device open failed\n\t%s", szError);
        return 0;
    }

    FDwfDigitalInInternalClockInfo(hdwf, &hzSys);
    FDwfDigitalInDividerSet(hdwf, (unsigned int)(0.5 + hzSys / 200e3)); // 200kMHz
    FDwfDigitalInSampleFormatSet(hdwf, 32); // 32 bit samples
    FDwfDigitalInBufferSizeSet(hdwf, cSamples);
    FDwfDigitalInConfigure(hdwf, false, true);
    do {
        if (!FDwfDigitalInStatus(hdwf, true, &sts)) return 0;
    } while (sts != stsDone);
    FDwfDigitalInStatusData(hdwf, rgdwSamples, cSamples * sizeof(unsigned int));
    for (int i = 0; i < cSamples && i < 30; i++)  printf("0x%08X\n", rgdwSamples[i]);
    FDwfDeviceCloseAll();
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...