?? drv_ledtimer.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 "16timer.h"
#include "common.h"
#include "int.h"
#include "presc.h"
#define TIME 6000000/4096
//時間設定
/* Prototype */
extern void vLEDOff( void );
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)
{
*(volatile unsigned char *)PRESC_P16TS0_ADDR = PRESC_PTONL_ON | PRESC_CLKDIVL_SEL7; // 時鐘源設定 (CLK/4096)
/* Set 16bit timer0 comparison match A data */
*(volatile unsigned short *)T16P_CR0A_ADDR = TIME; // 設定timer0比較寄存器
/* timer0 控制寄存器 */
*(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;
/*輸出普通模式/禁止數據buffer/輸出普通模式/選擇內部時鐘/關閉輸出控制/計數器復位為0/停止計數器//*/
/* Set 16bit timer0 interrupt CPU request on interrupt controller */
*(volatile unsigned char *)INT_RP0_RHDM_R16T0_ADDR &= 0x3f; // 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; // 清除timer0的比較器A中斷標志
/* 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");
*(volatile unsigned char *)INT_E16T0_E16T1_ADDR &= ~INT_E16TC0; //關閉中斷使能
*(volatile unsigned char *)T16P_PRUN0_ADDR &= ~T16P_PRUN_RUN; //停止定時器
*(volatile unsigned char *)T16P_PRUN0_ADDR |= T16P_PSET_ON; //復位定時器
*( volatile unsigned char * )0x402D1 |= 0x0f; //關燈
//打開鍵盤
*(volatile unsigned char *)INT_FP0_FK_ADDR &= 0xef; // 清除鍵盤中斷標志
*(volatile unsigned char *)INT_EP0_EK_ADDR |= 0x10; // 使能鍵盤總中斷
*(volatile unsigned char *)INT_F16T0_F16T1_ADDR &= ~INT_F16TC0; //清除中斷標志
*(volatile unsigned char *)INT_E16T0_E16T1_ADDR |= INT_E16TC0; //開啟中斷使能
asm("popn %r15");
asm("reti");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -