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

📄 drv_ledtimer.c

📁 使用键盘上的上、下、左、右四个按键
💻 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_lectimer(void);
void int_16timer_c0(void);
unsigned char ledflg=0;

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

	/* Set 16bit timer0 comparison match A data */
	*(volatile unsigned short *)T16P_CR0A_ADDR = 60000000 / 4096 * 1000 - 1;		// Set comparison match A data (0x4e ... 2ms on OSC3 clock 40MHz)

	/* 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_LVL3;

	/* 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;
}


/*******************************************************************************
 * int_16timer_c0
 *   Type :	void
 *   Ret val :	none
 *   Argument :	void
 *   Function :	16bit timer0 comparison match A interrupt function.
 *******************************************************************************/
void int_16timer_c0(void)
{       
	asm("pushn %r15");
	/*switch(ledflg)
	   {
	   	case 0:
	   	     *( volatile unsigned char * )0x402D1 &= ~0x08;
	   	     ledflg=1;
	   	     break;
	        case 1:
	             *( volatile unsigned char * )0x402D1 |= 0x08;
	             ledflg=0;
	             break;
	        }   	 
			*/
	*(volatile unsigned char *)T16P_PRUN0_ADDR &= ~T16P_PRUN_RUN;
	//vSinglight(4);
	*(volatile unsigned char *)INT_F16T0_F16T1_ADDR = INT_F16TC0;	// Reset 16bit timer0 comparison match A interrupt factor flag
	asm("popn %r15");
	asm("reti");
}



⌨️ 快捷键说明

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