FC_GetNsPerCPUClockCycle - General Information

Overview

Type:

Function

Available as of:

SystemInterface_1.32.6.0

Versions:

Current version

Task

Measure time high-precisely.

Description

The function outputs the length of time for a processor timer cycle in ns. The value can be used to convert into ns the value that the function FC_GetTSC() returns.

Return Value

Data type

Description

LREAL

GetNsPerCPUClockCycle: Number of ns per processor clock cycle

Example

Declaration

ulStartClock: UDINT;  
ulEndClock: UDINT;  
ulClock: UDINT;  
lrTimeUs: LREAL;  

Program

ulStartClock := FC_GetTSC(); 
: <zu messende Programmsequenz> 
ulEndClock:= FC_GetTSC(); 
ulClock := ulEndClock - ulStartClock; 
lrTimeUs:= UDINT_TO_LREAL(ulClock) * FC_GetNsPerCPUClockCycle() /1000.0;