您的位置 首页 FPGA

NXP_LPC1114延时函数调集

includeLPC11XXhincludegpiohincludetimer16h*系统时钟配置为48MHz,AHB不分频,一次定时器时钟为48Mhz,因此得出以下

#include “LPC11XX.h”

#include “gpio.h”
#include “timer16.h”
/*体系时钟装备为48MHz,AHB不分频,一次定时器时钟为48Mhz,因而得出以下分频值,匹配值*/
void Delay_Us(unsigned int DelayTimes)
{
/* * setup timer #1 for delay */
//LPC_SYSCON->SYSAHBCLKCTRL |= (1<<8); /*敞开定时器Timer16_1时钟--时钟装备中敞开该时钟*/
LPC_TMR16B1->TCR = 0x02; /* reset timer */
LPC_TMR16B1->PR = 48; /* set prescaler to zero 依据AHB时钟确认分频值*/
LPC_TMR16B1->MR0 = DelayTimes; /* 所需的延时时刻 */
LPC_TMR16B1->IR = 0xff; /* reset all interrrupts 复位一切的中止*/
LPC_TMR16B1->MCR = 0x04; /* stop timer on match –到达匹配中止*/
LPC_TMR16B1->TCR = 0x01; /* start timer 发动定时器*/
while (LPC_TMR16B1->TCR & 0x01); /*等候直到时刻到*/
LPC_TMR16B1->TCR = 0x00; /* Close timer –封闭定时器*/
}
void Delay_Ms(unsigned int DelayTimes)
{
/* * setup timer #1 for delay */
//LPC_SYSCON->SYSAHBCLKCTRL |= (1<<8); //敞开定时器Timer16_1时钟
LPC_TMR16B1->TCR = 0x02; /* reset timer */
LPC_TMR16B1->PR = 48000; /* set prescaler to zero */
LPC_TMR16B1->MR0 = DelayTimes;
LPC_TMR16B1->IR = 0xff; /* reset all interrrupts */
LPC_TMR16B1->MCR = 0x04; /* stop timer on match */
LPC_TMR16B1->TCR = 0x01; /* start timer */
while (LPC_TMR16B1->TCR & 0x01); /*等候直到时刻到*/
LPC_TMR16B1->TCR = 0x00; /* Close timer */
}
void Delay_Sec(unsigned char DelayTimes)
{
/* * setup timer #1 for delay */
//LPC_SYSCON->SYSAHBCLKCTRL |= (1<<8); //敞开定时器Timer16_1时钟
LPC_TMR16B1->TCR = 0x02; /* reset timer */
LPC_TMR16B1->PR = 48000000; /* set prescaler to zero */
LPC_TMR16B1->MR0 = DelayTimes;
LPC_TMR16B1->IR = 0xff; /* reset all interrrupts */
LPC_TMR16B1->MCR = 0x04; /* stop timer on match */
LPC_TMR16B1->TCR = 0x01; /* start timer */
while (LPC_TMR16B1->TCR & 0x01); /*等候直到时刻到*/
LPC_TMR16B1->TCR = 0x00; /* Close timer */
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/fangan/fpga/255600.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部