l_d_jabc@yahoo. 该用户已被删除
|
写 mc9s12dg128b输入脉冲计数程序时总是无法计数,是不是寄存器没有设置好.程序如下:
#include /* common defines and macros */
#include /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
#define hs TFLG1_C0F
uint t;
void ini_all(void){
TIOS_IOS0=0;
TIOS_IOS1=0; //输入通道选择01
TCTL4=0b00001101;
TSCR1_TEN=1;
TSCR1_TFFCA=1;
ICPAR_PA1EN=1;
DDRB=0XFF;
PORTB=0XFF;
}
void inputcapture(void){
TSCR2 = 0b10001011; /* TCNT prescaler setup */
if(hs){
t=TC1;
PORTB=t;
while (TCNT != 0x0000);
while (TCNT == 0x0000);
}
}
void main(void) {
ini_all();
//EnableInterrupts;
inputcapture();
//for(;;) {} /* wait forever */
/* please make sure that you never leave this function */
}
|
|