标题:
【求助】ECT多路捕捉中断冲突
[打印本页]
作者:
mumuyumutou
时间:
2009-11-25 23:37
标题:
【求助】ECT多路捕捉中断冲突
所用单片机为HCS12DP512,采集6路转速,但发现只能采集2路,而且数据不稳定,漂的厉害。程序如下:初始化:
void ECT_init(void){
TSCR1=0x90;
TSCR2_PR=0x04;
ICSYS = 0x0A;
TIOS = 0x00;
TCTL3=0x51;
TCTL4=0x54;
ICOVW = 0xF0;
TFLG1 = 0xFF;
DLYCT=0x02;
TIE_C1I=1;
TIE_C2I=1;
TIE_C3I=1;
TIE_C4I=1;
TIE_C6I=1;
TIE_C7I=1;
中断处理如下:
void interrupt 15 ECT7_Rx(void){
TFLG1_C7F = 1;
TC7;
if(TC7>IC_TEMP7) {
IC_Period7 = TC7 - IC_TEMP7;
}
else {
IC_Period7=0xFFFF-IC_TEMP7+TC7;
}
IC_TEMP7=TC7;
}
void interrupt 14 ECT6_Rx(void){
TC6;
if(TC6>IC_TEMP6) {
IC_Period6 = TC6 - IC_TEMP6;
}
else{
IC_Period6=0xFFFF-IC_TEMP6+TC6;
}
IC_TEMP6=TC6;
}
void interrupt 9 ECT1_RX(void){
TFLG1_C1F = 1;
first1=TC1H;
second1=TC1;
if(second1>first1){
IC_Period1=second1-first1;
}
else{
IC_Period1=0xFFFF+second1-first1;
}
}
void interrupt 10 ECT2_RX(void){
TFLG1_C2F = 1;
first2=TC2H;
second2=TC2;
if(second2>first2){
IC_Period2=second2-first2;
}
else{
IC_Period2=0xFFFF-first2+second2;
}
}
void interrupt 11 ECT3_RX(void){
first3=TC3H;
second3=TC3;
if(second3>first3){
IC_Period3=second3-first3;
}
else{
IC_Period3=0xFFFF-first3+second3;
}
}
void interrupt 12 ECT4_Rx(void){
TC4;
if(TC4>IC_TEMP4){
IC_Period4 = TC4 - IC_TEMP4;
}
else{
IC_Period4=0xFFFF-IC_TEMP4+TC4;
}
IC_TEMP4=TC4;
}
请达人帮忙,谢谢。
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/)
Powered by Discuz! 7.0.0