查看: 922|回复: 0

在pcDuino上添加实时时钟(RTC)

[复制链接]
  • TA的每日心情
    奋斗
    2016-4-25 13:46
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]初来乍到

    发表于 2013-6-6 19:16:38 | 显示全部楼层 |阅读模式
    分享到:
    pcDuino通过连接Linker RTC 模块 可以实现时间日期的自动同步功能,这个模块使用了DS1307芯片,连接pcDuino时使用的是I2C接口。
    接线图如下:
    GND of Linker RTC -> GND of pcDuino
    VCC of Linker RTC -> 5V of pcDuino
    SDA of Linker RTC -> SDA of pcDuino
    SCL of Linker RTC -> SCL of pcDuino

    获取pcDuino的Arduio-ish C 环境:
    如果没有安装git:

    用以下命令获取:

    用代码测试Link RTC模块:
    在目录 c_enviroment/sample下找到 “linker_rtc_test.c”文件,可执行文件位于 “c_enviroment/output/test”。
    设置日期/时间:
    a ./linker_rtc_test [Year] [Month] [Date] [Hour] [Minute] [Second].
    b 在终端检查输出
    注意: [Year] [Month] [Date] [Hour] [Minute] [Second] 是可选参数
    用代码来设置日期/时间:
    当pcDuino启动时,会自动运行 script /etc/rc.local,从 Linker RTC调用读取日期/时间的程序并设置系统日期。
    [download id="1920"]




    可执行文件要添加到 /etc/rc.local
    使用“sudo vi /etc/rc.local”,在 “exit 0″前插入下面这行

    这样就完成了,在不联网时也可以获取正确的日期时间。
    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条

    手机版|小黑屋|与非网

    GMT+8, 2024-4-16 17:32 , Processed in 0.117739 second(s), 17 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.