智能车制作

标题: 寄存器怎么就不清零了呢!!!!! [打印本页]

作者: dreamprosper    时间: 2008-7-5 02:48
标题: 寄存器怎么就不清零了呢!!!!!
我们的测速程序,大家帮忙看一下:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIOS=0x00; // PT0-2 is set to be IC (input capture) mode<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TCTL4=0b00000000; // ÎÊÌâ³öÔÚÕâÀïÁË£¿ // Õâ¸öÐèÒª¸ÄһϠ//<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ICOVW_NOVW3=1; // protected<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ICPAR_PA3EN=1; // enable pulse accumulator 3<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TSCR2=0x07; // Õâ¸öÇáÒײ»Òª¸ÄÁË£¬ÊÔÁËÎÞÊý±éÁË 128·ÖƵ<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // disable INTERUPT when TCNT overflow<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TSCR1=0x80; // enable timer TCNT, activate bit TEN<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TIOS=0x00; // PT0-PT2 are set to be IC (input captured) mode<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TCTL4_EDG1A=1; // capture on rising edges or falling edges<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TCTL4_EDG1B=0; //shangshengyan bu zhuo<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ICOVW_NOVW1=0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ICSYS_BUFEN=1; // open hold register<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ICSYS_TFMOD=1; // after transfer the data to hold register, set the flagC3F<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ICSYS_LATQ=0; // apply queue mode&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //a1 = TC1; // read data from IC register<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //a2 = TC1H; // read data from holding register<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SP = TC1 - TC1H; // obtain the current speed<br><br><br><br>这个是读的通道寄存和保持寄存的差值,在单位时间内的脉冲个数差值<br><br>问题是TC1 和TCIH 不是清零,读回来的SP 就不准啊,拜托大家帮忙看看,怎么能让TC1和TCIH清零呢!!!!<br><br><br>谢谢<br>
作者: auto    时间: 2008-7-5 19:37
标题: Re:寄存器怎么就不清零了呢!!!!!
TC1是不用清的,是记录
作者: dreamprosper    时间: 2008-7-5 19:41
标题: Re:寄存器怎么就不清零了呢!!!!!
那怎么测速轮都不转了,还显示上次的脉冲数呢?




欢迎光临 智能车制作 (http://dns.znczz.com/) Powered by Discuz! X3.2