ClearCore Library
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions | Variables
SysTiming.h File Reference

ClearCore timing profiling utility functions. More...

#include <stdint.h>
+ Include dependency graph for SysTiming.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ClearCore::SysTiming
 ClearCore system timing class. More...
 

Namespaces

namespace  ClearCore
 Namespace to encompass the ClearCore board API.
 

Macros

#define CPU_CLK   120000000
 
#define _CLEARCORE_SAMPLE_RATE_HZ   (5000)
 
#define MS_TO_SAMPLES   (_CLEARCORE_SAMPLE_RATE_HZ / 1000)
 
#define CYCLES_PER_INTERRUPT   (CPU_CLK / _CLEARCORE_SAMPLE_RATE_HZ)
 
#define SAMPLE_PERIOD_MICROSECONDS   (1000000UL / _CLEARCORE_SAMPLE_RATE_HZ)
 
#define CYCLES_PER_MICROSECOND   (CPU_CLK / 1000000)
 
#define CYCLES_PER_MILLISECOND   (CPU_CLK / 1000)
 
#define CYCLES_PER_SECOND   (CPU_CLK)
 

Functions

uint32_t Milliseconds (void)
 Number of milliseconds since the ClearCore was initialized.
 
uint32_t Microseconds (void)
 Number of microseconds since the ClearCore was initialized.
 
void Delay_cycles (uint64_t cycles)
 Blocks for operations cycles CPU cycles.
 
void Delay_ms (uint32_t ms)
 Blocks operations for ms milliseconds.
 
void Delay_us (uint32_t usec)
 Blocks for operations usec microseconds.
 

Variables

const uint16_t ClearCore::SampleRateHz = _CLEARCORE_SAMPLE_RATE_HZ
 

Detailed Description

ClearCore timing profiling utility functions.

Macro Definition Documentation

◆ _CLEARCORE_SAMPLE_RATE_HZ

#define _CLEARCORE_SAMPLE_RATE_HZ   (5000)

ClearCore sample rate for main interrupt processing (5 kHz).

◆ CPU_CLK

#define CPU_CLK   120000000

Number of CPU cycles, in Hz. (120MHz)

Examples
DigitalIOExamples/PeriodicInterrupt/PeriodicInterrupt.cpp, and PeriodicInterrupt.cpp.

◆ CYCLES_PER_INTERRUPT

#define CYCLES_PER_INTERRUPT   (CPU_CLK / _CLEARCORE_SAMPLE_RATE_HZ)

Number of CPU cycles per interrupt time (24,000).

◆ CYCLES_PER_MICROSECOND

#define CYCLES_PER_MICROSECOND   (CPU_CLK / 1000000)

Number of CPU cycles per microsecond (120).

◆ CYCLES_PER_MILLISECOND

#define CYCLES_PER_MILLISECOND   (CPU_CLK / 1000)

Number of CPU cycles per millisecond (120,000).

◆ CYCLES_PER_SECOND

#define CYCLES_PER_SECOND   (CPU_CLK)

Number of CPU cycles per second (120,000,000).

◆ MS_TO_SAMPLES

#define MS_TO_SAMPLES   (_CLEARCORE_SAMPLE_RATE_HZ / 1000)

ClearCore sample rate, expressed in sample times (5).

◆ SAMPLE_PERIOD_MICROSECONDS

#define SAMPLE_PERIOD_MICROSECONDS   (1000000UL / _CLEARCORE_SAMPLE_RATE_HZ)

ClearCore sample time, expressed in microseconds (200us).

Function Documentation

◆ Delay_cycles()

void Delay_cycles ( uint64_t  cycles)

Blocks for operations cycles CPU cycles.

Parameters
[in]cyclesTime in CPU cycles to delay

◆ Delay_ms()

void Delay_ms ( uint32_t  ms)
inline

Blocks operations for ms milliseconds.

Parameters
[in]msTime in milliseconds to delay
Examples
Abs16PositionsHomeToHardStop.cpp, Abs2PositionsHomeToSwitch.cpp, Abs4PositionsHomeToHardStop.cpp, AnalogIOExamples/ReadAnalogInput/ReadAnalogInput.cpp, AnalogIOExamples/WriteAnalogCurrentOutput/WriteAnalogCurrentOutput.cpp, AsgWithMeasuredTorque.cpp, CCIO8Examples/ClearCoreIOExpansionBoard/ClearCoreIOExpansionBoard.cpp, CCIO8Examples/ReadCCIODigitalInput/ReadCCIODigitalInput.cpp, CCIO8Examples/WriteCCIODigitalOutput/WriteCCIODigitalOutput.cpp, CCIO8Examples/WriteCCIODigitalOutputPulses/WriteCCIODigitalOutputPulses.cpp, ClearCoreBoardStatus/ClearCoreStatusRegister/ClearCoreStatusRegister.cpp, ClearCoreCommandProtocol.cpp, ClearCoreIOExpansionBoard.cpp, ClearCoreStatusRegister.cpp, ClearPathModeExamples/ClearPath-MC_Series/Abs16PositionsHomeToHardStop/Abs16PositionsHomeToHardStop.cpp, ClearPathModeExamples/ClearPath-MC_Series/Abs2PositionsHomeToSwitch/Abs2PositionsHomeToSwitch.cpp, ClearPathModeExamples/ClearPath-MC_Series/Abs4PositionsHomeToHardStop/Abs4PositionsHomeToHardStop.cpp, ClearPathModeExamples/ClearPath-MC_Series/FollowDigitalPosition/FollowDigitalPosition.cpp, ClearPathModeExamples/ClearPath-MC_Series/FollowDigitalTorque/FollowDigitalTorque.cpp, ClearPathModeExamples/ClearPath-MC_Series/FollowDigitalVelocity/FollowDigitalVelocity.cpp, ClearPathModeExamples/ClearPath-MC_Series/FollowDigitalVelocityWithVariableTorque/FollowDigitalVelocityWithVariableTorque.cpp, ClearPathModeExamples/ClearPath-MC_Series/ManualVelocity/ManualVelocity.cpp, ClearPathModeExamples/ClearPath-MC_Series/Move2IncrementsHomeToSwitch/Move2IncrementsHomeToSwitch.cpp, ClearPathModeExamples/ClearPath-MC_Series/Move4IncrementsHomeToHardStop/Move4IncrementsHomeToHardStop.cpp, ClearPathModeExamples/ClearPath-MC_Series/PulseBurstPositioning/PulseBurstPositioning.cpp, ClearPathModeExamples/ClearPath-MC_Series/RampUpDownToSelectedVelocity/RampUpDownToSelectedVelocity.cpp, ClearPathModeExamples/ClearPath-SD_Series/DualAxisSynchronized/DualAxisSynchronized.cpp, ClearPathModeExamples/ClearPath-SD_Series/MotorStatusRegister/MotorStatusRegister.cpp, ClearPathModeExamples/ClearPath-SD_Series/MovePositionAbsolute/MovePositionAbsolute.cpp, ClearPathModeExamples/ClearPath-SD_Series/MovePositionRelative/MovePositionRelative.cpp, ClearPathModeExamples/ClearPath-SD_Series/MoveVelocity/MoveVelocity.cpp, ClearPathModeExamples/ClearPath-SD_Series/UserSeeksHome/UserSeeksHome.cpp, ClearPathModeExamples/High-Level_Feedback_HLFB/AsgWithMeasuredTorque/AsgWithMeasuredTorque.cpp, ClearPathModeExamples/High-Level_Feedback_HLFB/SpeedOutput/SpeedOutput.cpp, DigitalIOExamples/InputInterrupts/InputInterrupts.cpp, DigitalIOExamples/PlayTone/PlayTone.cpp, DigitalIOExamples/ReadDigitalInput/ReadDigitalInput.cpp, DigitalIOExamples/ReadDigitalInputRiseFall/ReadDigitalInputRiseFall.cpp, DigitalIOExamples/WriteDigitalOutput/WriteDigitalOutput.cpp, DigitalIOExamples/WriteHBridgeOutput/WriteHBridgeOutput.cpp, DigitalIOExamples/WritePwmOutput/WritePwmOutput.cpp, DualAxisSynchronized.cpp, EthernetExamples/EthernetTcpClientHelloWorld/EthernetTcpClientHelloWorld.cpp, EthernetExamples/EthernetTcpServerHelloWorld_automatic/EthernetTcpServerHelloWorld_automatic.cpp, EthernetExamples/EthernetTcpServerHelloWorld_manual/EthernetTcpServerHelloWorld_manual.cpp, EthernetExamples/EthernetUdpHelloWorld/EthernetUdpHelloWorld.cpp, EthernetTcpClientHelloWorld.cpp, EthernetTcpServerHelloWorld_automatic.cpp, EthernetTcpServerHelloWorld_manual.cpp, EthernetUdpHelloWorld.cpp, FollowDigitalPosition.cpp, FollowDigitalTorque.cpp, FollowDigitalVelocity.cpp, FollowDigitalVelocityWithVariableTorque.cpp, InputInterrupts.cpp, ManualVelocity.cpp, MotorStatusRegister.cpp, Move2IncrementsHomeToSwitch.cpp, Move4IncrementsHomeToHardStop.cpp, MovePositionAbsolute.cpp, MovePositionRelative.cpp, MoveVelocity.cpp, PlayTone.cpp, PulseBurstPositioning.cpp, RampUpDownToSelectedVelocity.cpp, ReadAnalogInput.cpp, ReadCCIODigitalInput.cpp, ReadDigitalInput.cpp, ReadDigitalInputRiseFall.cpp, ReadSerialInput.cpp, SerialCommExamples/ClearCoreCommandProtocol/ClearCoreCommandProtocol.cpp, SerialCommExamples/ReadSerialInput/ReadSerialInput.cpp, SpeedOutput.cpp, StepAndDirection.cpp, StepAndDirectionExamplesNonClearPath/StepAndDirectionNonClearPath/StepAndDirection.cpp, UserSeeksHome.cpp, WriteAnalogCurrentOutput.cpp, WriteCCIODigitalOutput.cpp, WriteCCIODigitalOutputPulses.cpp, WriteDigitalOutput.cpp, WriteHBridgeOutput.cpp, and WritePwmOutput.cpp.

◆ Delay_us()

void Delay_us ( uint32_t  usec)
inline

◆ Microseconds()

uint32_t Microseconds ( void  )

Number of microseconds since the ClearCore was initialized.

Uses the processor's cycle counter register to calculate the number of microseconds elapsed.

Returns
Microseconds
Note
Rolls over every ~71.5 minutes (at UINT32_MAX microseconds)

◆ Milliseconds()

uint32_t Milliseconds ( void  )

Number of milliseconds since the ClearCore was initialized.

Uses the fast update interrupt counter to retrieve the number of milliseconds elapsed.

Returns
milliseconds
Note
Rolls over every ~49.7 days (at UINT32_MAX milliseconds)
Examples
Abs16PositionsHomeToHardStop.cpp, Abs2PositionsHomeToSwitch.cpp, Abs4PositionsHomeToHardStop.cpp, AnalogIOExamples/ReadAnalogInput/ReadAnalogInput.cpp, AsgWithMeasuredTorque.cpp, CCIO8Examples/ClearCoreIOExpansionBoard/ClearCoreIOExpansionBoard.cpp, CCIO8Examples/ReadCCIODigitalInput/ReadCCIODigitalInput.cpp, ClearCoreBoardStatus/ClearCoreStatusRegister/ClearCoreStatusRegister.cpp, ClearCoreIOExpansionBoard.cpp, ClearCoreStatusRegister.cpp, ClearPathModeExamples/ClearPath-MC_Series/Abs16PositionsHomeToHardStop/Abs16PositionsHomeToHardStop.cpp, ClearPathModeExamples/ClearPath-MC_Series/Abs2PositionsHomeToSwitch/Abs2PositionsHomeToSwitch.cpp, ClearPathModeExamples/ClearPath-MC_Series/Abs4PositionsHomeToHardStop/Abs4PositionsHomeToHardStop.cpp, ClearPathModeExamples/ClearPath-MC_Series/FollowDigitalPosition/FollowDigitalPosition.cpp, ClearPathModeExamples/ClearPath-MC_Series/FollowDigitalTorque/FollowDigitalTorque.cpp, ClearPathModeExamples/ClearPath-MC_Series/FollowDigitalVelocity/FollowDigitalVelocity.cpp, ClearPathModeExamples/ClearPath-MC_Series/FollowDigitalVelocityWithVariableTorque/FollowDigitalVelocityWithVariableTorque.cpp, ClearPathModeExamples/ClearPath-MC_Series/ManualVelocity/ManualVelocity.cpp, ClearPathModeExamples/ClearPath-MC_Series/Move2IncrementsHomeToSwitch/Move2IncrementsHomeToSwitch.cpp, ClearPathModeExamples/ClearPath-MC_Series/Move4IncrementsHomeToHardStop/Move4IncrementsHomeToHardStop.cpp, ClearPathModeExamples/ClearPath-MC_Series/PulseBurstPositioning/PulseBurstPositioning.cpp, ClearPathModeExamples/ClearPath-MC_Series/RampUpDownToSelectedVelocity/RampUpDownToSelectedVelocity.cpp, ClearPathModeExamples/ClearPath-SD_Series/DualAxisSynchronized/DualAxisSynchronized.cpp, ClearPathModeExamples/ClearPath-SD_Series/MotorStatusRegister/MotorStatusRegister.cpp, ClearPathModeExamples/ClearPath-SD_Series/MovePositionAbsolute/MovePositionAbsolute.cpp, ClearPathModeExamples/ClearPath-SD_Series/MovePositionRelative/MovePositionRelative.cpp, ClearPathModeExamples/ClearPath-SD_Series/MoveVelocity/MoveVelocity.cpp, ClearPathModeExamples/ClearPath-SD_Series/UserSeeksHome/UserSeeksHome.cpp, ClearPathModeExamples/High-Level_Feedback_HLFB/AsgWithMeasuredTorque/AsgWithMeasuredTorque.cpp, ClearPathModeExamples/High-Level_Feedback_HLFB/SpeedOutput/SpeedOutput.cpp, DigitalIOExamples/InputInterrupts/InputInterrupts.cpp, DigitalIOExamples/ReadDigitalInput/ReadDigitalInput.cpp, DigitalIOExamples/ReadDigitalInputRiseFall/ReadDigitalInputRiseFall.cpp, DualAxisSynchronized.cpp, EncoderInputExamples/FollowEncoder/FollowEncoder.cpp, EthernetExamples/EthernetTcpClientHelloWorld/EthernetTcpClientHelloWorld.cpp, EthernetExamples/EthernetTcpServerHelloWorld_automatic/EthernetTcpServerHelloWorld_automatic.cpp, EthernetExamples/EthernetTcpServerHelloWorld_manual/EthernetTcpServerHelloWorld_manual.cpp, EthernetExamples/EthernetUdpHelloWorld/EthernetUdpHelloWorld.cpp, EthernetTcpClientHelloWorld.cpp, EthernetTcpServerHelloWorld_automatic.cpp, EthernetTcpServerHelloWorld_manual.cpp, EthernetUdpHelloWorld.cpp, FollowDigitalPosition.cpp, FollowDigitalTorque.cpp, FollowDigitalVelocity.cpp, FollowDigitalVelocityWithVariableTorque.cpp, FollowEncoder.cpp, InputInterrupts.cpp, ManualVelocity.cpp, MotorStatusRegister.cpp, Move2IncrementsHomeToSwitch.cpp, Move4IncrementsHomeToHardStop.cpp, MovePositionAbsolute.cpp, MovePositionRelative.cpp, MoveVelocity.cpp, PulseBurstPositioning.cpp, RampUpDownToSelectedVelocity.cpp, ReadAnalogInput.cpp, ReadCCIODigitalInput.cpp, ReadDigitalInput.cpp, ReadDigitalInputRiseFall.cpp, SpeedOutput.cpp, StepAndDirection.cpp, StepAndDirectionExamplesNonClearPath/StepAndDirectionNonClearPath/StepAndDirection.cpp, and UserSeeksHome.cpp.