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

📄 cap1.c

📁 飞思卡尔单片机MC9SDG128B的脉冲捕获程序
💻 C
字号:
/** ###################################################################
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : Cap1.C
**     Project   : Capture
**     Processor : MC9S12DG128BCPV
**     Beantype  : Capture
**     Version   : Bean 02.108, Driver 01.10, CPU db: 2.87.280
**     Compiler  : Metrowerks HC12 C Compiler
**     Date/Time : 2008-3-5, 上午 09:42
**     Abstract  :
**         This bean "Capture" simply implements the capture function
**         of timer. The counter counts the same way as in free run mode. On
**         the selected edge of the input signal (on the input pin), the current
**         content of the counter register is written into the capture
**         register and the OnCapture event is called.
**     Settings  :
**             Timer capture encapsulation : Capture
**
**         Timer
**             Timer                   : ECT
**             Counter shared          : Yes
**
**         High speed mode
**             Prescaler               : divide-by-32
**           Maximal time for capture register
**             Xtal ticks              : 4194304
**             microseconds            : 262144
**             milliseconds            : 262
**             seconds (real)          : 0.2621440
**             Hz                      : 4
**           One tick of timer is
**             microseconds            : 4
**
**         Initialization:
**              Timer                  : Enabled
**              Events                 : Enabled
**
**         Timer registers
**              Capture                : TC2       [84]
**              Counter                : TCNT      [68]
**              Mode                   : TIOS      [64]
**              Run                    : TSCR1     [70]
**              Prescaler              : TSCR2     [77]
**
**         Used input pin              : 
**             ----------------------------------------------------
**                Number (on package)  |    Name
**             ----------------------------------------------------
**                       11            |  PT2_IOC2
**             ----------------------------------------------------
**
**         Port name                   : T
**         Bit number (in port)        : 2
**         Bit mask of the port        : 4
**
**         Signal edge/level           : falling
**         Priority                    : 1
**         Pull option                 : off
**
**     Contents  :
**         Reset           - byte Cap1_Reset(void);
**         GetCaptureValue - byte Cap1_GetCaptureValue(word *Value);
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2005
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/


/* MODULE Cap1. */

#include "Events.h"
#include "Cap1.h"

#pragma DATA_SEG Cap1_DATA
#pragma CODE_SEG Cap1_CODE

volatile word Cap1_CntrState;          /* Content of counter */

/*
** ===================================================================
**     Method      :  Cap1_Reset (bean Capture)
**
**     Description :
**         This method resets the counter register.
**     Parameters  : None
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
** ===================================================================
*/
/*
byte Cap1_Reset(word *Value)

**  This method is implemented as a macro. See Cap1.h file.  **
*/

/*
** ===================================================================
**     Method      :  Cap1_GetCaptureValue (bean Capture)
**
**     Description :
**         This method gets the last value captured by enabled timer.
**         Note: one tick of timer is
**               4 us in high speed mode 
**     Parameters  :
**         NAME            - DESCRIPTION
**       * Value           - A pointer to the content of the
**                           capture register
**     Returns     :
**         ---             - Error code, possible codes:
**                           ERR_OK - OK
**                           ERR_SPEED - This device does not work in
**                           the active speed mode
** ===================================================================
*/
/*
byte Cap1_GetCaptureValue(word *Value)

**  This method is implemented as a macro. See Cap1.h file.  **
*/

/*
** ===================================================================
**     Method      :  Cap1_Init (bean Capture)
**
**     Description :
**         Initializes the associated peripheral(s) and the beans 
**         internal variables. The method is called automatically as a 
**         part of the application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void Cap1_Init(void)
{
  Cap1_CntrState = 0;                  /* Initial state of variable */
  TFLG1 = 4;                           /* Reset interrupt request flag */
  TIE_C2I = 1;                         /* Enable interrupt */
  /* TCTL4: EDG2B=1 */
  TCTL4 |= 32;                         /* Enable capture function */
}

/*
** ===================================================================
**     Method      :  Interrupt (bean Capture)
**
**     Description :
**         The method services the interrupt of the selected peripheral(s)
**         and eventually invokes the beans event(s).
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
#pragma CODE_SEG __NEAR_SEG NON_BANKED
ISR(Cap1_Interrupt)
{
  /* TFLG1: C7F=0,C6F=0,C5F=0,C4F=0,C3F=0,C2F=1,C1F=0,C0F=0 */
  TFLG1 = 4;                           /* Reset interrupt request flag */
  Cap1_OnCapture();                    /* Invoke user event */
}

#pragma CODE_SEG Cap1_CODE

/* END Cap1. */

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 2.96 [03.76]
**     for the Freescale HCS12 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

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