freescale
来自「Freescale 系列单片机常用模块与综合系统设计」· 代码 · 共 142 行
TXT
142 行
/** ###################################################################
** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
** Filename : TIMER_1S.C
** Project : digital_timer
** Processor : MC9S08JM60CLHE
** Component : TimerInt
** Version : Component 02.157, Driver 01.18, CPU db: 3.00.046
** Compiler : CodeWarrior HCS08 C Compiler
** Date/Time : 2010-1-11, 19:39
** 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 : TPM1 (16-bit)
** Compare name : TPM10
** Counter shared : No
**
** High speed mode
** Prescaler : divide-by-1
** Clock : 46875 Hz
** Initial period/frequency
** Xtal ticks : 12000000
** microseconds : 1000000
** milliseconds : 1000
** seconds : 1
** seconds (real) : 1.0
** Hz : 1
**
** Runtime setting : none
**
** Initialization:
** Timer : Enabled
** Events : Enabled
**
** Timer registers
** Counter : TPM1CNT [$0021]
** Mode : TPM1SC [$0020]
** Run : TPM1SC [$0020]
** Prescaler : TPM1SC [$0020]
**
** Compare registers
** Compare : TPM1C0V [$0026]
**
** Flip-flop registers
** Mode : TPM1C0SC [$0025]
** Contents :
** No public methods
**
** Copyright : 1997 - 2009 Freescale Semiconductor, Inc. All Rights Reserved.
**
** http : www.freescale.com
** mail : support@freescale.com
** ###################################################################*/
/* MODULE TIMER_1S. */
#include "Events.h"
#include "PE_Error.h"
#include "TIMER_1S.h"
#pragma MESSAGE DISABLE C2705 /* WARNING C2705: Possible loss of data */
#pragma MESSAGE DISABLE C5919 /* WARNING C5919: Conversion of floating to unsigned integral */
#pragma MESSAGE DISABLE C5703 /* WARNING C5703: Parameter X declared in function F but not referenced */
#pragma MESSAGE DISABLE C4002 /* Disable warning C4002 "Result not used" */
/*** Internal macros and method prototypes ***/
/*
** ===================================================================
** Method : SetCV (component TimerInt)
**
** Description :
** The method computes and sets compare eventually modulo value
** for time measuring.
** This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
#define TIMER_1S_SetCV(_Val) ( \
TPM1C0V = (word)(_Val), \
TPM1MOD = (word)(_Val) )
/*** End of internal method prototypes ***/
/*
** ===================================================================
** Method : TIMER_1S_Init (component TimerInt)
**
** 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 TIMER_1S_Init(void)
{
/* TPM1SC: TOF=0,TOIE=0,CPWMS=0,CLKSB=0,CLKSA=0,PS2=0,PS1=0,PS0=0 */
setReg8(TPM1SC, 0x00); /* Stop HW; disable overflow interrupt and set prescaler to 0 */
/* TPM1C0SC: CH0F=0,CH0IE=1,MS0B=0,MS0A=1,ELS0B=0,ELS0A=0,??=0,??=0 */
setReg8(TPM1C0SC, 0x50); /* Set output compare mode and enable compare interrupt */
TIMER_1S_SetCV(0xB71AU); /* Inicialize appropriate value to the compare/modulo/reload register */
/* TPM1CNTH: BIT15=0,BIT14=0,BIT13=0,BIT12=0,BIT11=0,BIT10=0,BIT9=0,BIT8=0 */
setReg8(TPM1CNTH, 0x00); /* Reset HW Counter */
/* TPM1SC: TOF=0,TOIE=0,CPWMS=0,CLKSB=1,CLKSA=0,PS2=0,PS1=0,PS0=0 */
setReg8(TPM1SC, 0x10); /* Set prescaler and run counter */
}
/*
** ===================================================================
** Method : TIMER_1S_Interrupt (component TimerInt)
**
** 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.
** ===================================================================
*/
ISR(TIMER_1S_Interrupt)
{
/* TPM1C0SC: CH0F=0 */
clrReg8Bits(TPM1C0SC, 0x80); /* Reset compare interrupt request flag */
TIMER_1S_OnInterrupt(); /* Invoke user event */
}
/* END TIMER_1S. */
/*
** ###################################################################
**
** This file was created by Processor Expert 3.07 [04.34]
** for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?