⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 timer.c

📁 移植在鱼板上运行的ucos
💻 C
字号:
#include "includes.h"
/*************************************************************************/
/*                                                                       */
/* NAME : tm_init(timer device, time periode)                            */
/*                                                                       */
/* FUNCTIONS : Initialize the TIMER0,1.                                  */
/*                                                                       */
/* EXAMPLES :                                                            */
/*             tm_init(TIMER_DEV0,ONE_SECOND/TICKS_PER_SECOND);          */
/*                                                                       */
/*               Where, the TIMER_DEV0 means timer0.                     */
/*                          ONE_SECOND = 1000,                           */
/*                          TICKS_PER_SECOND = 100,                      */
/*                then timer0 timer periode become to 10ms.              */
/*                                                                       */
/* VARIABLES USED                                                        */
/*                                                                       */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*         NAME            DATE                    REMARKS               */
/*                                                                       */
/*        in4maker      06-07-1999      Created initial version 1.0      */
/*                                                                       */
/*************************************************************************/
void tm_init(int TIMER_DEV, int t) 
{

   if(TIMER_DEV)  /* for TIMER 1 */
   {
         Disable_Int(nTIMER1_INT);    
	 	 SysSetInterrupt(nTIMER1_INT, OSTimeTick);
         TDATA1 = t_data_ms(t);    /* unit is [ms] */
         TCNT1 = 0x0;
         TMOD  = TM1_TOGGLE;       /* Toggle pulse will be out to port */
         Enable_Int(nTIMER1_INT);  /* Timer interrupt enable */
   }
   else  /* for TIMER0 */
   {
         Disable_Int(nTIMER0_INT);    
	 	 SysSetInterrupt(nTIMER0_INT, OSTimeTick);
         TDATA0 = t_data_ms(t);  
         TCNT0 = 0x0;
         TMOD  = TM0_TOGGLE;        
         Enable_Int(nTIMER0_INT); 
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -