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

📄 acprd_timer.c

📁 source code for a sample alarm control panel system using Freescale MC9S12DP256 . The project was im
💻 C
字号:
//=============================================================================
// File: ACPRD_TIMER.C - V1.00
// Rem.: The ACPRD Project Page on the Web -> http://hc12web.de/acprd
//=============================================================================

//-- Includes -----------------------------------------------------------------

#include "datatypes.h"
#include "hcs12dp256.h"
#include "s12_ect.h"
#include "acprd_timer.h"

//-- Static Vars --------------------------------------------------------------

void (*timer_handler)(void);

//-- Code ---------------------------------------------------------------------

void initTimer(void (*ufunc)(void)) {

	// timer enable, freeze while BDM
	TSCR1  = BM_TEN | BM_TSFRZ;
	// MDCU Interrupt enable, modulus mode, counter enable, MDC prescaler=4 
	MCCTL = BM_MCZI | BM_MODMC | BM_MCEN | BM_MCPR0;
	MCCNT = TIMER_MDC_COUNT;
	// if not NULL, this user function will be called cyclically
	timer_handler = ufunc;
	}

//-----------------------------------------------------------------------------

// ISR for Modulus Down Counter Underflow
//
#ifdef METROWERKS_C
interrupt
#endif
#ifdef IMAGECRAFT_C
#pragma interrupt_handler isrMDCU
#endif
void isrMDCU(void) {

	MCFLG = BM_MCZF;					// clear Intr flag
	if(timer_handler)
		(*timer_handler)();				// call user handler
	}

//=============================================================================

⌨️ 快捷键说明

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