📄 time_ect.c
字号:
/*********************************************************************/
/*********************************************************************/
/* TIME.c ------------ Hardware related functions
TIME_Init();
TIME_ECT_Init();
Int_TimerOverFlow();
Int_Timer7OverFlow(void);
Int_Timer6OverFlow(void);
Int_Timer5OverFlow(void);
Int_Timer4OverFlow(void);
Int_Timer3OverFlow(void);
Int_Timer2OverFlow(void);
Int_Timer1OverFlow(void);
Int_Timer0OverFlow(void);
**********************************************************************/
/*Time Initialization rounte*/
void TIME_Init(void)
{
TSCR2=128;
// TSCR2_PR = 0; //prescale factor is x, bus clock/2^x=8Mhz/2^0=8MHz/1
// TSCR2_TOI = 1; //timer overflow interrupt enable
// TSCR2_TCRE = 0; //定时器自由运行,不受OC7影响
PACTL=64;
// PACTL_PAEN=1;
// PACTL_CLK=1;
TSCR1=128;
// TSCR1_TEN = 1; //timer enable
}
/*ECT Time Initialization rounte*/
void TIME_ECT_Init(void)
{
TC0=0x2000; //设置比较值
TC1=0x4000;
TC3=0x6000;
TC4=0x8000;
TC5=0xA000;
TC6=0xC000;
TC7=0xE000;
TIE=0xFF; //打开多有中断
}
/*定时器中断*/
uchar i=0xF0;
#pragma CODE_SEG NON_BANKED//
#pragma TRAP_PROC//
void Int_TimerOverFlow(void)//
{//
// OS_ENTER_CRITICAL();
TFLG2=128;
// TFLG2_TOF = 1; //clear timer overflow flag
TCNT=0x0000; //
// i++;
// j=0-j;
PORTB=~i;
i=~i;
// PTP=j;
//
// OS_EXIT_CRITICAL();
}//
#pragma CODE_SEG DEFAULT//
#pragma CODE_SEG NON_BANKED//
#pragma TRAP_PROC//
void Int_Timer7OverFlow(void)
{
TFLG1 = 0xFF;//或者使用TFLG1_C7F=1;
/**编写用户处理代码**/
PORTB=0X00;
}
void Int_Timer6OverFlow(void)
{
TFLG1 = 0xFF; //或者使用TFLG1_C6F=1;
/**编写用户处理代码**/
PORTB=0XFF;
}
void Int_Timer5OverFlow(void)
{
TFLG1 = 0xFF;//或者使用TFLG1_C5F=1;
/**编写用户处理代码**/
PORTB=0X00;
}
void Int_Timer4OverFlow(void)
{
TFLG1 = 0xFF; //或者使用TFLG1_C4F=1;
/**编写用户处理代码**/
PORTB=0XFF;
}
void Int_Timer3OverFlow(void)
{
TFLG1 = 0xFF;//或者使用TFLG1_C3F=1;
/**编写用户处理代码**/
PORTB=0X00;
}
void Int_Timer2OverFlow(void)
{
TFLG1 = 0xFF; //或者使用TFLG1_C2F=1;
/**编写用户处理代码**/
PORTB=0XFF;
}
void Int_Timer1OverFlow(void)
{
TFLG1 = 0xFF;//或者使用TFLG1_C1F=1;
/**编写用户处理代码**/
PORTB=0X00;
}
void Int_Timer0OverFlow(void)
{
TFLG1 = 0xFF; //或者使用TFLG1_C0F=1;
/**编写用户处理代码**/
PORTB=0XFF;
}
#pragma CODE_SEG DEFAULT//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -