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

📄 tick.c

📁 这是一个嵌入式系统的ucos-ii的移植程序。
💻 C
字号:
/************************************************************************
 *									*
 *	Copyright (C) SEIKO EPSON CORP. 1999				*
 *									*
 *	File name: drv_16timer.c					*
 *	  This is 16bit timer driver program for E0C33208		*
 *	  demonstration.						*
 *									*
 *	Revision history						*
 *		1998.03.02	T.Mineshima	Start.			*
 *		1999.04.20	T.Mineshima	Modify prescaler	*
 *						setting.		*
 *									*
 ************************************************************************/

#include "..\include\16timer.h"
#include "..\include\common.h"
#include "..\include\int.h"
#include "..\include\presc.h"
/* Prototype */
void init_Tick(void);

/*unsigned char ledflg=0;*/

/*******************************************************************************
 * init_Tick
 *   Type :	void
 *   Ret val :	none
 *   Argument :	void
 *   Function :	Initialize 16bit timer0.
 *******************************************************************************/
void init_Tick(void)
{
	/* Set 16bit timer0 prescaler */
	*(volatile unsigned char *)PRESC_P16TS0_ADDR = PRESC_PTONL_ON | PRESC_CLKDIVL_SEL6;	// Set 16bit timer0 prescaler (CLK/4096)

	/* Set 16bit timer0 comparison match A data */
	//*(volatile unsigned short *)T16P_CR0A_ADDR = 60000000 / 4096 / 1000 * 1000 - 1;		// Set comparison match A data (0x4e ... 2ms on OSC3 clock 40MHz)
            *(volatile unsigned short *)T16P_CR0A_ADDR =0x92;
             *(volatile unsigned short *)T16P_CR0B_ADDR =0x92;
	/* Set 16bit timer0 mode */
	*(volatile unsigned char *)T16P_PRUN0_ADDR = T16P_SELFM_NOR | T16P_SELCRB_DIS | T16P_OUTINV_NOR | T16P_CKSL_INT | T16P_PTM_OFF | T16P_PSET_ON | T16P_PRUN_STOP;

	/* Set 16bit timer0 interrupt CPU request on interrupt controller */
	*(volatile unsigned char *)INT_RP0_RHDM_R16T0_ADDR |= INT_RIDMA_DIS;	// IDMA request disable and CPU request enable

	/* Set 16bit timer0 interrupt priority level 3 on interrupt controller */
	*(volatile unsigned char *)INT_P16T0_P16T1_ADDR |= INT_PRIL_LVL0;

	/* Reset 16bit timer0 interrupt factor flag on interrupt controller */
	*(volatile unsigned char *)INT_F16T0_F16T1_ADDR = INT_F16TC0;		// Reset 16bit timer0 comparison match A interrupt flag

	/* Set 16bit timer0 interrupt enable on interrupt controller */
	*(volatile unsigned char *)INT_E16T0_E16T1_ADDR |= INT_E16TC0;		// Set 16bit timer0 comparison match A interrupt enable
       
       // Run 16bit timer0 [0x4819E]
	*(volatile unsigned char *)T16P_PRUN0_ADDR |= T16P_PRUN_RUN;
}





⌨️ 快捷键说明

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