新聞中心

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

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

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

本文引用地址:http://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);	  //等待,即延時(shí)}/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);}}}



評(píng)論


技術(shù)專(zhuān)區(qū)

關(guān)閉