- UID
- 343877
- 性别
- 男
|
#include /* common defines and macros */
#include /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
int count;
void ECT_Init(void);
void ECT_Init(void)
{
TSCR2_PR = 7; //prescale factor is 8, bus clock/128=8Mhz/8
TSCR2_TOI = 1; //timer overflow interrupt enable
TSCR1_TEN = 1; //timer enable
DDRB=0xff;
PORTB=0x00;
INTCR &= ~64;
TIE_C0I=1;
count=0;
}
void main(void) {
/* put your own code here */
ECT_Init();
EnableInterrupts;
for(;;) {
PORTB=0xff;(程序执行到此指针跑飞)
} /* wait forever */
/* please make sure that you never leave this function */
}
#pragma CODE_SEG __NEAR_SEG NON_BANKED
void interrupt 8 ECT_IC0(void)
{
PORTB=0x0f;
TFLG2_TOF= 1;
for(;;){
PORTB=0xf0;
}
// TFLG2_TOF = 1; //clear timer overflow flag
//用户自己的代码
}
程序功能:
想要程序计数定时进入中断程序执行~
谢谢斑竹!! |
|