查看: 1737|回复: 0

[原创] Kinetis K60系列之LPTMR 延时

[复制链接]

该用户从未签到

16

主题

78

帖子

0

注册会员

Rank: 2

积分
178
最后登录
2018-6-1
发表于 2016-9-18 10:14:47 | 显示全部楼层 |阅读模式
延时函数
  1. void Delay(U32 time)
  2. {
  3.     SIM_SCGC5 |= SIM_SCGC5_LPTIMER_MASK;
  4.     LPTMR0_CMR = time;
  5.     LPTMR0_PSR = LPTMR_PSR_PCS(1) | LPTMR_PSR_PBYP_MASK;  //PCS:01 LPO——1KHz的时钟 PBYP:1
  6.     LPTMR0_CSR = LPTMR_CSR_TEN_MASK; //使能定时器
  7.     while (!(LPTMR0_CSR & LPTMR_CSR_TCF_MASK)); //延时 溢出复位
  8.     LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK; //清零
  9. }
复制代码
主函数

  1. void main(void)
  2. {

  3.     DisableInterrupts;

  4.     UART4_Init(115200);
  5.     FTM_PWM_Init();
  6.     FTM_INPUT_INIT();   
  7.     EnableInterrupts;

  8.     while(1)
  9.     {
  10.         Delay(1000);
  11.         count1=count;
  12.         count2=count>>8;
  13.         Uart4_SendByte(count2);
  14.         Uart4_SendByte(count1);
  15.         count=0;         
  16.     }
  17. }
复制代码
其余完全COPY上一篇代码……
22.png


1S收到的数据是0x0253
这样可以算出 不进行任何时钟配备 系统的总线时钟是 47.6MHZ(应该是48MHZ)



回复

使用道具 举报

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

本版积分规则

关闭

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

Archiver|手机版|小黑屋|恩智浦技术社区

GMT+8, 2024-4-26 05:26 , Processed in 0.119562 second(s), 21 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

快速回复 返回顶部 返回列表