计算机工程与应用 ›› 2013, Vol. 49 ›› Issue (4): 82-86.

• 理论研究、研发设计 • 上一篇    下一篇

嵌入式设备的精确时钟同步技术的研究与实现

陈大峰1,白瑞林1,邹骏宇2   

  1. 1.江南大学 轻工过程先进控制教育部重点实验室,江苏 无锡 214122
    2.无锡信捷电气有限公司,江苏 无锡 214072
  • 出版日期:2013-02-15 发布日期:2013-02-18

Research and implementation of precision clock synchronization in embedded devices

CHEN Dafeng1, BAI Ruilin1, ZOU Junyu2   

  1. 1.Key Laboratory of Advanced Process Control for Light Industry(Ministry of Education), Jiangnan University, Wuxi, Jiangsu 214122, China
    2.Xinjie Electronic Co., Ltd., Wuxi, Jiangsu 214072, China
  • Online:2013-02-15 Published:2013-02-18

摘要: 为解决工业以太网中嵌入式设备之间时钟同步能力不足的问题,提出了IEEE1588协议在嵌入式设备中的应用方案。基于STM32F207IG处理器和ucos-II操作系统软硬件平台,首先移植并修改LwIP协议使其兼容IEEE 1588协议,然后配置系统时间校准模式,将捕获的时间戳以增强型描述符的形式交于应用层进行时钟校正,采用频率漂移校正算法解决从时钟频率漂移的问题,使用秒脉冲信号测试时钟同步。实验测试表明,时钟同步精度约200 ns,满足了大部分工业以太网的需求。

关键词: IEEE1588, 时钟同步, 精确时钟协议(PTP), 时间戳, 嵌入式设备, 频率漂移

Abstract: In order to solve the issue of the clock synchronization between industrial Ethernet embedded devices, the application scheme of IEEE1588 protocol in embedded devices is proposed. Based on the software and hardware platform of STM32F207IG processor and ucos-II OS, the transplant and modification of LwIP protocol stack is needed to make it compatible with the IEEE1588 protocol. The clock calibration method is configured. The application layer calibrates clock using the enhanced descriptors to access the time stamp captured. The correction algorithm is proposed to solve frequency drift. Pulse per second is used to test clock synchronization. Experiments show that the system achieves 200 ns clock synchronization precision, and meets the needs of most industrial Ethernet devices.

Key words: IEEE1588, clock synchronization, Precision Time Protocol(PTP), time stamp, embedded device, frequency drift