MSP430定时器调试不成功 财富值25 语音偷听 邀请guogongjian回答

2019-11-26 13:35发布

<pre style="max-width: 100%;"><code class="cpp hljs" codemark="1"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span> <span class="hljs-meta-string">&lt;msp430x14x.h&gt;</span></span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> t=<span class="hljs-number">0</span>, time=<span class="hljs-number">0</span>; <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">main</span> <span class="hljs-params">(<span class="hljs-keyword">void</span>)</span> </span>{ WDTCTL=WDTPW+WDTHOLD; P2DIR = <span class="hljs-number">0x01</span>; P2OUT=<span class="hljs-number">0xfe</span>; <span class="hljs-comment">//点亮LED灯</span> TACTL=TASSEL1+TACLR+ID0+ID1+MC0+TAIE; CCR0=<span class="hljs-number">9999</span>; _EINT(); <span class="hljs-keyword">while</span>(<span class="hljs-number">1</span>) { IF (t==<span class="hljs-number">1</span>) 当t=一时实现LED灯反转 { t=<span class="hljs-number">0</span>; time++; <span class="hljs-keyword">if</span>(time==<span class="hljs-number">100</span>) { time=<span class="hljs-number">0</span>; P2OUT=<span class="hljs-number">0xfe</span>|(~P2OUT&amp;BIT0); } } } } <span class="hljs-meta">#<span class="hljs-meta-keyword">pragma</span> vector=TIMERA1_VECTOR</span> __<span class="hljs-function">nterrupt <span class="hljs-keyword">void</span> <span class="hljs-title">timer_A</span> <span class="hljs-params">(<span class="hljs-keyword">void</span>)</span> </span>{ <span class="hljs-keyword">switch</span>(TAIV) <span class="hljs-comment">//TAIV选择溢出中短</span> { <span class="hljs-keyword">case</span> <span class="hljs-number">2</span>:<span class="hljs-keyword">break</span>; <span class="hljs-keyword">case</span> <span class="hljs-number">4</span>:<span class="hljs-keyword">break</span>; <span class="hljs-keyword">case</span> <span class="hljs-number">10</span>:t=<span class="hljs-number">1</span>;<span class="hljs-keyword">break</span>; } } </code></pre> <br> <p><br></p>
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
2条回答
提着灯笼寻找爱
1楼 · 2019-11-26 15:11.采纳回答获得作者2.5元分成
CCR0中断入口向量是TIMERA0_VECTOR 不是TIMERA1_VECTOR。
提着灯笼寻找爱
2楼-- · 2019-11-26 16:07
TIMERA0 是独立的中断向量,在中断服务函数里面不要 用TAIV

一周热门 更多>