是个用TA1捕获中断的小程序,实在解决不了了,求高手指教
#include "cc430f5137.h"
void main(void)
{
WDTCTL=WDTPW+WDTHOLD;
/*设置时钟,系统上电复位后主时钟和SMCLK为DCO,ACLK为VLO*/
//P2.0输出ACLK
PMAPPWD = 0x02D52; // Get write-access to port mapping regs
P2MAP0 = PM_ACLK; // Map ACLK output to P2.0
P2MAP2 = PM_TA1CCR1A; // Map TA1 CCR1输入 P2.2
PMAPPWD = 0; // Lock port mapping registers
TA1CTL = TASSEL_1+MC_1+ID__2+TACLR+TAIE; //SMCLK,UP,4分频,定时器清除,中断使能
TA1CCTL1 = CM_2+CCIS_0+SCS+CAP+CCIE; //下降沿,CCI0A,同步,捕获,中断使能
TA1CCR1=12000;
P2SEL = 0x05;
P2DIR = 0xC1; //P2.2片内外设输入CCI0A p2.6红灯
while(1)
{
__bis_SR_register( LPM0_bits+GIE);
P2OUT ^= BIT7;
__no_operation(); //DEBUGE
}
}
#pragma vector=TIMER1_A1_VECTOR
__interrupt void TIMER1_A1_ISR(void)
{
switch(__even_in_range(TA1IV,14))
{
case 0: break;
case 2: P2OUT ^= BIT6;
delayms(50);
ccr1_LSB = TA1CCR1; //
slp--;
__no_operation(); //DEBUGE
LPM0_EXIT;
break;
case 4: break; // CCR2
case 6: break; // CCR3 not used
case 8: break; // CCR4 not used
case 10: break; // CCR5 not used
case 12: break; // Reserved not used
case 14: break;
default: break;
}
}
问题是程序一直不会执行到P2OUT ^= BIT7;可是中断后有LPM0_EXIT; 啊?还有就是 ccr1_LSB 值不变ccr1_LSB = TA1CCR1; 这句该怎么写啊?刚接触430,求高手指教,谢谢!
此帖出自
小平头技术问答
一周热门 更多>