Camera Link PCI Express (PCIe) Gen1 Framegrabbers
Appendix C: Timestamping
EDT, Inc.
2012 March 16
33
The following C++ struct encapsulates this footer structure, including showing the struct with bit fields
representing the packed BCD values from the IRIG signal.
// ts_raw_t is defined in libedt_timing.h
// Packed BCD from IRIGB
typedefstruct { // Raw timecode format
u_long seconds:6;
u_long minutes:6;
u_long hours:5;
u_long days:9; // days in the year
u_long years:6;
} ts_raw_t;
// This structure is defined in pdv_irig.h
typedef struct Irig2Record {
u_int magic; /* magic */
u_int framecnt; /* starts at 0 */
/* There are two modes - seconds from 1970 (Unix time) or BCD mode, in which the BCD
values from IRIG are packed into 32 bits in the raw structure */
union {u_int seconds;
ts_raw_t raw;
} t;
u_int clocks; /* how many 40 MHz ticks in last second */
u_int tickspps; /* 40 MHz ticks since last second */
struct { /* status bits */
u_char type: 4;
u_char irig_ok:1;
u_char pps_ok:1;
u_char had_irig_error:1;
u_char had_pps_error:1;
} status;
u_char reserved[3];
double timestamp; /* holds a 64-bit unix seconds time */
/* This must be filled in by software */
} Irig2Record;
IRIG time
8
4
One of two types:
packed raw BCD,
or Unix seconds.
Type is indicated
by a bit in the
status register.
For IRIG time, the raw format is:
6 bits seconds
6 bits minutes
5 bits hours
9 bits days
6 bits years
Unix seconds = seconds since 1/1/1970 (without leap seconds)
40 MHz count
12
4
u_int
Counts using onboard 40 MHz clock since last pulse per second
40 MHz maximum ticks
at last pulse
16
4
u_int
Counts at last pulse per second (pps).
Status
20
1
u_char
Status bits:
0–3 = footer type (3 = Unix seconds; 5 = IRIG BCD)
4 = has valid IRIG data
5 = is synched with pps
6 = has seen IRIG error
7 = has seen pps error
Reserved
21
3
u_char
Reserved.
Monotonic Unix time
with fractional seconds
24
8
double
This value is computed and filled in by the library after DMA.
Fractional time is the 40 MHz count divided by 40 MHz max count
Table 8. Elements of IRIG2 Footer, part 2 of 2
Element
Offset
Size
Type
Notes