Agilent Technologies N5183A MXG User Manual

Page 226

Advertising
background image

216

Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide

Creating and Downloading Waveform Files
Creating Waveform Data

Line

Code—Interleaving and Byte Swapping for Little Endian Order

20
21
22
23
24
25
26
27
28
29
30

char iqbuffer[NUMSAMPLES*4];

for(index=0; index<numsamples; index++)

{

short ivalue = idata[index];

short qvalue = qdata[index];

iqbuffer[index*4] = (ivalue >> 8) & 0xFF;

iqbuffer[index*4+1] = ivalue & 0xFF;

iqbuffer[index*4+2] = (qvalue >> 8) & 0xFF;

iqbuffer[index*4+3] = qvalue & 0xFF;

}

return 0;

Line

Code Description—Interleaving and Byte Swapping for Little Endian Order

20

Define a character array to store the interleaved I and Q data. The character array makes byte swapping
easier, since each array location accepts only 8 bits (1 byte). The array size increases by four times to
accommodate two bytes of I data and two bytes of Q data.

21–29

Create a loop to do the following:

Save the current I data array value to a variable.

NOTE

In rare instances, a compiler may define short as larger than 16 bits. If this condition exists,
replace short with the appropriate object or label that defines a 16- bit integer.

Save the current Q data array value to a variable.

Swap the low bytes (bits 0–7) of the data with the high bytes of the data (done for both

Advertising
This manual is related to the following products: