Spectrum Brands MC.31XX 用户手册

下载
页码 102
86
MC.31xx Manual
Example programs
Option Timestamp
Example programs
Standard acquisition mode
Acquisition with Multiple Recording
 
// ----- Allocate memory for the timestamp data buffer -----
plTimeStamps = (ptr32) malloc (MAX_TIMESTAMPS * 8);
// ----- Reset the board and flush the FIFO -----
SpcSetParam (hDrv, SPC_COMMAND,        SPC_RESET);
// ----- Setup and start timestamp module -----
SpcSetParam (hDrv, SPC_TIMESTAMP_CMD,  TS_MODE_STANDARD);  // Standard mode set
SpcSetParam (hDrv, SPC_TIMESTAMP_CMD,  TS_RESET);          // Counter is set to Zero
// ----- Start the board 4 times to generate 4 timestamps -----
for (i=0; i<4; i++)
    {
    SpcSetParam (hDrv, SPC_COMMAND,        SPC_START);     // Start recording
    do
        {
        SpcGetParam (hDrv, SPC_STATUS, &lStatus);          // Wait for Status Ready
        }
    while (lStatus != SPC_READY);
    }
// ----- Read out and display the timestamps -----
SpcGetData (hDrv, CH_TIMESTAMP, (int32) &lCount, MAX_TIMESTAMPS, (dataptr) plTimeStamps);
for (i=0; i<lCount; i++)
    printf ("Timestamp: %d\tHIGH: %08lx\tLOW: %08lx\n", i, plTimeStamps[2*i+1], plTimeStamps[2*i]);
    
// ----- Free the allocated memory for the timestamp data buffer -----
free (plTimeStamps);
}
// ----- Reset the board and flush the FIFO -----
SpcSetParam (hDrv, SPC_COMMAND,        SPC_RESET);
// ----- Simple setup for recording -----
SpcSetParam (hDrv, SPC_CHENABLE,    1);                   // 1 channel for recording
SpcSetParam (hDrv, SPC_SAMPLERATE,  1000000);             // Samplerate 1 MHz.
SpcSetParam (hDrv, SPC_TRIGGERMODE, TM_TTLPOS);           // External positive Edge
SpcSetParam (hDrv, SPC_MULTI,       1);                   // Enable Multiple Recording
SpcSetParam (hDrv, SPC_MEMSIZE,     8192);                // 8k Memsize
SpcSetParam (hDrv, SPC_POSTTRIGGER, 1024);                // Each segment 1k = 8 segments
SpcSetParam (hDrv, SPC_MULTI,       1);                   // Enable Multiple Recording
// ----- Setup and start timestamp module -----
SpcSetParam (hDrv, SPC_TIMESTAMP_CMD,  TS_MODE_STANDARD); // Standard Timestamp mode set
SpcSetParam (hDrv, SPC_TIMESTAMP_CMD,  TS_RESET);         // Counter is set to Zero
// ----- Start the board -----
SpcSetParam (hDrv, SPC_COMMAND,        SPC_START);        // Start recording
do
    {
    SpcGetParam (hDrv, SPC_STATUS, &lStatus);             // Wait for Status Ready
    }
while (lStatus != SPC_READY);
// ----- Read out the timestamps -----
SpcGetData (hDrv, CH_TIMESTAMP, (int32) &lCount, 8, (dataptr) plTimeStamps);
// ----- display the timestamps (There should be 8 stamps, 1 for each segment) -----
for (i=0; i<lCount; i++)
    printf (“Segment: %d   Counter: %08lx %08lx\n”, i, plTimeStamps[2*i+1], plTimeStamps[2*i]);