没有板子,用PROTUES仿真,一涉及到中断等时就出错,各位看看,帮小弟一把,感激涕零!#include <msp430x14x.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3DIR |= BIT4; // P3.4 output
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 20000;
TACTL = TASSEL_2 + MC_1; // SMCLK, upmode
__bis_SR_register(CPUOFF+GIE); //************** PROTUES仿真出错点(据我猜测)*******************//
//__low_power_mode_0();
//_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
P3OUT ^= BIT4; // Toggle P3.4
}
[
本帖最后由 1274250091 于 2012-5-1 16:31 编辑 ]
此帖出自
小平头技术问答
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 |= XTS; // ACLK= LFXT1= HF XTAL
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0xFF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
BCSCTL2 |= SELM_3; // MCLK= LFXT1 (safe)
P1SEL |= 0x0E; // P1.1 - P1.3 option select
P1DIR |= 0x0F; // P1.0 - P1.3 outputs
CCTL0 = OUTMOD_4 + CCIE; // CCR0 toggle, interrupt enabled
CCTL1 = OUTMOD_4 + CCIE; // CCR1 toggle, interrupt enabled
CCTL2 = OUTMOD_4 + CCIE; // CCR2 toggle, interrupt enabled
CCR0 = 200;
CCR1 = 1000;
CCR2 = 10000;
TACTL = TASSEL_1 + MC_2 + TAIE; // ACLK, contmode, interrupt enabled
_EINT();while(1);
// _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}
// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A0 (void)
{
CCR0 += 200; // Add Offset to CCR0
}
// Timer_A3 Interrupt Vector (TAIV) handler
#pragma vector=TIMERA1_VECTOR
__interrupt void Timer_A1(void)
{
switch( TAIV )
{
case 2: CCR1 += 1000; // Add Offset to CCR1
break;
case 4: CCR2 += 10000; // Add Offset to CCR2
break;
case 10: P1OUT ^= 0x01; // Timer_A3 overflow
break;
}
}
这个Ti的例程 为何软件仿真时TAR总是0啊?也就是没有进入定时器中断
一周热门 更多>