新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > LPC1768之系統(tǒng)滴答定時器

LPC1768之系統(tǒng)滴答定時器

作者: 時間:2016-11-19 來源:網(wǎng)絡(luò) 收藏
滴答定時器可作為實時系統(tǒng)的滴答時鐘。MDK新建工程完成后,添加core_me.h到工程,static __INLINE uint32_t SysTick_Config(uint32_t ticks),在core_m3.h文件中。初始化時候調(diào)用即可。然后直接添加定時器中斷處理函數(shù)即可。

本文引用地址:http://m.butianyuan.cn/article/201611/318496.htm
/*	  *	main.c:  the main file *	NXP --> LPC1768**   *	Author	:	light					*	Date	:	2012-4-16  **/#includevolatile uint32_t msTicks;                            /* counts 1ms timeTicks *//*----------------------------------------------------------------------------SysTick_Handler*----------------------------------------------------------------------------*//Descriptions			:SysTick interrupt handleparameters			:NoneReturned value		:None*/void SysTick_Handler(void) {msTicks++;                        /* increment counter necessary in Delay() */}/*------------------------------------------------------------------------------delays number of tick Systicks (happens every 1 ms)*------------------------------------------------------------------------------*/__INLINE static void Delay (uint32_t dlyTicks) {uint32_t curTicks;	  curTicks = msTicks;	    // 獲取當(dāng)前值while ((msTicks - curTicks) < dlyTicks);	  //等待,即延時}/Descriptions			:Function that initializes LEDsparameters			:NoneReturned value		:None*/void DelayMs(unsigned int m){int i,j;for(i=m;i>0;i--){for(j=3000;j>0;j--);}}/Descriptions			:Function that initializes LEDsparameters			:NoneReturned value		:None*/void LedInit(void) {// PINSEL4,PINSEL5 設(shè)定P2.0 -- P2.32 端口功能(00,01,10,11)LPC_PINCON->PINSEL4 = 0XFC000000;			// p2.0--p2.13設(shè)置為IO LPC_PINCON->PINMODE4 = 0XFC000000;			// p2.0--p2.13設(shè)置為上拉電阻使能LPC_GPIO2->FIODIR = 0X000000FF;	 		// p2.0--p2.7設(shè)置為輸出}/Descriptions			:Function that LED onparameters			:n , which led is onReturned value		:None*/void LedNOn(unsigned int n){LPC_GPIO2->FIOSET = (1<FIOCLR = (1<=0;loc--){LedNOn(loc);Delay(1000);LedNOff(loc);Delay(1000);}}}



評論


技術(shù)專區(qū)

關(guān)閉