完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
程序如下:
void delayMs(uint8_t timer_num, uint32_t delayInMs) { if ( timer_num == 0 ) { LPC_TIM0->TCR = 0x02; /* reset timer */ LPC_TIM0->PR = 0x00; /* set prescaler to zero */ LPC_TIM0->MR0 = delayInMs * (9000000 / 1000-1); LPC_TIM0->IR = 0xff; /* reset all interrrupts */ LPC_TIM0->MCR = 0x04; /* stop timer on match */ LPC_TIM0->TCR = 0x01; /* start timer */ /* wait until delay time has elapsed */ while (LPC_TIM0->TCR & 0x01); } else if ( timer_num == 1 ) { LPC_TIM1->TCR = 0x02; /* reset timer */ LPC_TIM1->PR = 0x00; /* set prescaler to zero */ LPC_TIM1->MR0 = delayInMs * (9000000 / 1000-1); LPC_TIM1->IR = 0xff; /* reset all interrrupts */ LPC_TIM1->MCR = 0x04; /* stop timer on match */ LPC_TIM1->TCR = 0x01; /* start timer */ /* wait until delay time has elapsed */ while (LPC_TIM1->TCR & 0x01); } return; } 程序中的9000000是怎么算出来的,求大神解答!!! 谢谢!! |
|
相关推荐
1个回答
|
|
|
9000000代表你单片机定时器的时钟是9Mhz,9M/1000得到每毫秒的计数值(因为1秒=1000毫秒),再乘以delayInMs得到n毫秒所需要的计数值,至于定时器时钟为什么是9M,对照芯片手册上时钟部分仔细算算就知道了。
|
|
|
|
|
只有小组成员才能发言,加入小组>>
2135个成员聚集在这个小组
加入小组我的项目我做主,使用GN+Ninja来完成构建系统(VSCode开发RT106X)
37379 浏览 0 评论
NXP IMX8应用处理器快速入门必备:技巧、使用、设计指南
6778 浏览 1 评论
7796 浏览 1 评论
7646 浏览 0 评论
NXP i.MX6UL开发板(linux系统烧录+规格+硬件+模块移植)使用手册
5074 浏览 0 评论
1559浏览 2评论
关于NINA-W132 Wi-Fi模块SPI通信遇到的疑问求解
1211浏览 2评论
如何在MPC PowerPC MCU上首次刷写后禁用BDM?
750浏览 1评论
将HFREFR和LFREFR寄存器值设置为错误的值来将故障注入CMU,但CMU_ISR值始终为零,为什么?
737浏览 1评论
将SPSDK for FRDM-MCX-W71 SDK与VS一起安装时出现hidapi构建错误怎么解决?
681浏览 1评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-3 09:32 , Processed in 0.513883 second(s), Total 43, Slave 36 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
16103