timer.c
来自「freescale芯片9s12dp256的示例程序」· C语言 代码 · 共 30 行
C
30 行
#include <mc9s12c32.h> /* derivative information */
#include "can.h"
#include "pwm.h"
#include "sci.h"
#include "timer.h"
#include "event.h"
#pragma CODE_SEG DEFAULT
void TIM_Init(void)
{
TC0 = 0xC34F; // Store given value to the compare register
TC7 = 0xC34F; // Store given value to the modulo register
TSCR2_PR = 0X04; // Store given value to the prescaler
TFLG1 = 0x01; // Reset interrupt request flag
TIE_C0I = 1; // Enable interrupt
TIOS_IOS0 = 1;
TSCR1_TEN = 1; // Enable Timer
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED // Interrupt section for this module. Placement will be in NON_BANKED area.
interrupt 8 void TI2_Interrupt(void)
{
TFLG1 = 0x01; // Reset interrupt request flag
TIM_OnInterrupt(); // Invoke user event
}
#pragma CODE_SEG DEFAULT
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?