Skip to main content
  • 产品
  • Software evaluation
  • 下载
  • Free utilities
  • 购买
  • 芯片厂商
  • 支持
  • 关于我们
  • Search
  • 工作机会
  • 新闻简报
  • 联系我们
  • embOS
  • Cycle Precise System Time

    Cycle precise system time

    Use highly accurate timings with embOS.

    Contact us
    Downloads
    Documentation
    SEGGER embOS

    embOS supports cycle precise run-time measurements that may be used for calculating timings in your application.

    embOS offers API functions to retrieve the current system time in timer cycle resolution.The actual resolution depends on your hardware timer frequency. For example if your hardware timer runs at 400 MHz, one timer cycle equals 1 sec / 400.000.000 cycles = 2,5 nano seconds per cycle.

    This feature is easy to use and can be utilized with any embOS board support package. An application merely needs to set up this feature with a simple API call to OS_TIME_ConfigSysTimer(). This is already done for most embOS board support package, and may swiftly be done for any further embOS board support package on request.

    OS_TIME_GetCycles() returns the current system time in timer cycles as a 64-bit value:

    void MeasureTime(void) {
      OS_U64 tStart
      OS_U64 tEnd;
    
      tStart = OS_TIME_GetCycles();
      DoSomeThing();
      tEnd= OS_TIME_GetCycles();
      printf("Time to run the function: %u cycles", tEnd - tStart);
    }
    

    With this 64-bit data type OS_TIME_GetCycles() can return up to 0xFFFFFFFFFFFFFFFF cycles (~18 quintillion cycles). That ensures you can even measure very long time periods without any overflow. For example with the above timer frequency of 400 MHz you can measure time periods up to ~1462 years.

    embOS offers API functions to convert the timer cycles into nano seconds or micro seconds:

    void Convert(void) {
      OS_U64 cycles;
      OS_U64 nano_sec;
      OS_U64 micro_sec;
    
      cycles    = OS_TIME_GetCycles();
      nano_sec  = OS_TIME_ConvertCycles2ns(cycles);
      micro_sec = OS_TIME_ConvertCycles2us(cycles);
    }

    embOS also offers API functions for micro second precise timings:

    void MeasureTime(void) {
      OS_U64 tStart
      OS_U64 tEnd;
    
      tStart = OS_TIME_Getus64();
      DoSomeThing();
      tEnd = OS_TIME_Getus64();
      printf("Time to run the function: %u micro seconds", tEnd - tStart);
    }
    • User manual
    • Online documentation
    • Knowledge Base
    • List of downloads
    • Release notes
    • Update notification
    • Pricing
    • Support
    • Silicon vendor resources

    全球总部

    德国: SEGGER Microcontroller GmbH

    地址: Ecolab-Allee 5
    40789 Monheim am Rhein, Germany
    电邮: info@segger.com
    电话: +49-2173-99312-0
    传真: +49-2173-99312-28

    网点分布

    中国:哲戈微系统科技(上海)有限公司

    地址: 中国上海市闵行区秀涟路133号
    大虹桥国际A 栋218室
    邮编201199
    电邮: china@segger.com
    电话: +86-133-619-907-60


    简易信息聚合

    通过ISO 9001认证

    ISO 9001

    30多年的嵌入式行业经验

    First-class embedded software tools since 1992
    • 版本说明
    • 免责声明
    • 行为准则
    • 隐私策略
    • 沪ICP备2022005181号
    • 沪公网安备 31011202014525号
    © 2026 SEGGER - 版权所有.

    您即将离开 segger.cn 而访问境外网站,是否继续?