欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5621|回復(fù): 0
收起左側(cè)

NXP_LPC1114延時(shí)函數(shù)集合

[復(fù)制鏈接]
ID:73735 發(fā)表于 2015-2-18 23:19 | 顯示全部樓層 |閱讀模式
#include "LPC11XX.h"
#include "gpio.h"
#include "timer16.h"

/*系統(tǒng)時(shí)鐘配置為48MHz,AHB不分頻,一次定時(shí)器時(shí)鐘為48Mhz,因此得出以下分頻值,匹配值*/
void Delay_Us(unsigned int DelayTimes)
{
/* * setup timer #1 for delay */

//LPC_SYSCON->SYSAHBCLKCTRL |= (1<<8);     /*開啟定時(shí)器Timer16_1時(shí)鐘--時(shí)鐘配置中開啟該時(shí)鐘*/
  LPC_TMR16B1->TCR = 0x02;                 /* reset timer */
  LPC_TMR16B1->PR  = 48;                   /* set prescaler to zero 根據(jù)AHB時(shí)鐘確定分頻值*/
  LPC_TMR16B1->MR0 = DelayTimes;             /* 所需的延時(shí)時(shí)間 */
  LPC_TMR16B1->IR  = 0xff;                 /* reset all interrrupts 復(fù)位所有的中斷*/
  LPC_TMR16B1->MCR = 0x04;                 /* stop timer on match --達(dá)到匹配停止*/
  LPC_TMR16B1->TCR = 0x01;                 /* start timer 啟動(dòng)定時(shí)器*/
  
while (LPC_TMR16B1->TCR & 0x01);           /*等待直到時(shí)間到*/
LPC_TMR16B1->TCR = 0x00;                 /* Close timer --關(guān)閉定時(shí)器*/
}
void Delay_Ms(unsigned int DelayTimes)
{
/* * setup timer #1 for delay */

//LPC_SYSCON->SYSAHBCLKCTRL |= (1<<8);       //開啟定時(shí)器Timer16_1時(shí)鐘
  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);           /*等待直到時(shí)間到*/
LPC_TMR16B1->TCR = 0x00;                 /* Close timer */
}
void Delay_Sec(unsigned char DelayTimes)
{
/* * setup timer #1 for delay */

//LPC_SYSCON->SYSAHBCLKCTRL |= (1<<8);       //開啟定時(shí)器Timer16_1時(shí)鐘
  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);           /*等待直到時(shí)間到*/
LPC_TMR16B1->TCR = 0x00;                 /* Close timer */
}



回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表