linux 内核时间打印

struct timespec ts;
ts = current_kernel_time();
printk(KERN_ALERT "i=%d, channel=%d, %ld %ld\n", i, channel, ts.tv_sec, ts.tv_nsec);

struct timeval tv;
/*获取时间*/
do_gettimeofday(&tv);
printk(KERN_ALERT "now: %ld %ld\n", tv.tv_sec, tv.tv_usec);

/*设置时间, 时钟调后5小时*/
ts.tv_sec = tv.tv_sec + 3600*5;
do_settimeofday(&ts);

报文调试:

i=0, channel=0, 1523614738 199999523
now: 1523614738 207424
i=0, channel=1, 1523614738 199999523
now: 1523614738 223716
i=0, channel=2, 1523614738 219999522
now: 1523614738 273299
i=0, channel=3, 1523614738 269999520
now: 1523614738 280457
i=0, channel=4, 1523614738 289999519
now: 1523614738 299316
i=0, channel=5, 1523614738 289999519
now: 1523614738 313382
i=0, channel=6, 1523614738 309999519
now: 1523614738 319441
i=0, channel=7, 1523614738 309999519
now: 1523614738 343332
i=1, channel=0, 1523614738 359999517
now: 1523614738 366732
i=1, channel=1, 1523614738 359999517
now: 1523614738 374799
i=1, channel=2, 1523614738 369999516
now: 1523614738 380832
i=1, channel=3, 1523614738 379999516
now: 1523614738 387841
i=1, channel=4, 1523614738 379999516
now: 1523614738 423382
i=1, channel=5, 1523614738 419999514
now: 1523614738 429524
i=1, channel=6, 1523614738 419999514
now: 1523614738 473382
i=1, channel=7, 1523614738 469999512
now: 1523614738 479674
i=2, channel=0, 1523614738 469999512
now: 1523614738 503307
i=2, channel=1, 1523614738 499999511
now: 1523614738 509524
i=2, channel=2, 1523614738 499999511
now: 1523614738 533374
i=2, channel=3, 1523614738 529999510
now: 1523614738 539407
i=2, channel=4, 1523614738 539999510
now: 1523614738 548157
i=2, channel=5, 1523614738 539999510
now: 1523614738 555924
i=2, channel=6, 1523614738 549999509
now: 1523614738 562524
i=2, channel=7, 1523614738 589999508
now: 1523614738 597291
i=3, channel=0, 1523614738 589999508
now: 1523614738 605132

ADC5通道每次会采样10次,耗时800ms,平均一次是80ms,由于电源监控芯片CAT809TBL在检测到低电平时会存在最小140ms的延时,所以ADC采样10次,去掉最大、最小值,然后取平均值,可以规避这个问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值