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

📄 ti1.c

📁 FREESCALE 16位单片机片MC9S12DG128的定时器程序,可调整定时时间
💻 C
字号:
/** ###################################################################
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : TI1.C
**     Project   : ESV1_0_DJ64
**     Processor : MC9S12DJ64BCFU
**     Beantype  : TimerInt
**     Version   : Bean 02.063, Driver 01.05, CPU db: 2.87.238
**     Compiler  : Metrowerks HC12 C Compiler
**     Date/Time : 2006-6-10, 10:56
**     Abstract  :
**         This bean "TimerInt" implements a periodic interrupt.
**         When the bean and its events are enabled, the "OnInterrupt"
**         event is called periodically with the period that you specify.
**         TimerInt supports also changing the period in runtime.
**         The source of periodic interrupt can be timer compare or reload 
**         register or timer-overflow interrupt (of free running counter).
**     Settings  :
**         Timer name                  : ECT (16-bit)
**         Compare name                : TC0
**         Counter shared              : No
**
**         High-speed CPU mode
**             Prescaler               : divide-by-8
**             Clock                   : 1000000 Hz
**           Initial period/frequency
**             Xtal ticks              : 800000
**             microseconds            : 50000
**             milliseconds            : 50
**             seconds (real)          : 0.0500000
**             Hz                      : 20
**
**         Runtime setting             : none
**
**         Initialization:
**              Timer                  : Enabled
**              Events                 : Enabled
**
**         Timer registers
**              Counter                : TCNT      [68]
**              Mode                   : TIOS      [64]
**              Run                    : TSCR1     [70]
**              Prescaler              : TSCR2     [77]
**
**         Compare registers
**              Compare                : TC0       [80]
**
**         Flip-flop registers
**              Mode                   : TCTL2     [73]
**     Contents  :
**         No public methods
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2002
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/


/* MODULE TI1. */

#include "Events.h"
#include "TI1.h"

/* Definition of DATA and CODE segments for this bean. User can specify where
   these segments will be located on "Build options" tab of the selected CPU bean. */
#pragma DATA_SEG TI1_DATA              /* Data section for this module. */
#pragma CODE_SEG TI1_CODE              /* Code section for this module. */



/*
** ===================================================================
**     Method      :  SetCV (bean TimerInt)
**
**     Description :
**         This method is internal. It is used by Processor Expert
**         only.
** ===================================================================
*/
static void SetCV(word Val)
{
  TC0 = Val;                           /* Store given value to the compare register */
  TC7 = Val;                           /* Store given value to the modulo register */
}

/*
** ===================================================================
**     Method      :  SetPV (bean TimerInt)
**
**     Description :
**         This method is internal. It is used by Processor Expert
**         only.
** ===================================================================
*/
static void SetPV(byte Val)
{
  TSCR2_PR = Val;                      /* Store given value to the prescaler */
}

/*
** ===================================================================
**     Method      :  TI1_Init (bean TimerInt)
**
**     Description :
**         This method is internal. It is used by Processor Expert
**         only.
** ===================================================================
*/
void TI1_Init(void)
{
  SetCV(50000);                        /* Store appropriate value to the compare register according to the selected high speed CPU mode */
  SetPV(3);                            /* Set prescaler register according to the selected high speed CPU mode */
  TFLG1 = 1;                           /* Reset interrupt request flag */
  TIE_C0I = 1;                         /* Enable interrupt */
}

/*
** ===================================================================
**     Method      :  TI1_Interrupt (bean TimerInt)
**
**     Description :
**         This method is internal. It is used by Processor Expert
**         only.
** ===================================================================
*/
#pragma CODE_SEG __NEAR_SEG NON_BANKED /* Interrupt section for this module. Placement will be in NON_BANKED area. */
__interrupt void TI1_Interrupt(void)
{
  TFLG1 = 1;                           /* Reset interrupt request flag */
  TI1_OnInterrupt();                   /* Invoke user event */
}

#pragma CODE_SEG TI1_CODE              /* Code section for this module. */

/* END TI1. */

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 03.33 for 
**     the Motorola HCS12 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

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