定时器中断和串口中断服务函数结束时没有继续运行主程序,但是中断服务函数依然可以正常进入,
#include "driverlib.h"
/* Application Defines */
#define TIMER_PERIOD 0x2DC6
/* Timer_A UpMode Configuration Parameter */
const Timer_A_UpModeConfig upConfig =
{
TIMER_A_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
TIMER_A_CLOCKSOURCE_DIVIDER_64, // SMCLK/1 = 3MHz
65535, // 5000 tick period
TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer interrupt
TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE , // Enable CCR0 interrupt
TIMER_A_DO_CLEAR // Clear value
};
vu32 u1=1;
int main(void)
{
Usart1tInit();
SystemClockInit();
led_init();
/* Stop WDT */
MAP_WDT_A_holdTimer();
/* Configuring P1.0 as output */
MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);
MAP_GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);
/* Configuring Timer_A1 for Up Mode */
MAP_Timer_A_configureUpMode(TIMER_A1_BASE, &upConfig);
/* Enabling interrupts and starting the timer */
MAP_Interrupt_enableSleepOnIsrExit();
MAP_Interrupt_enableInterrupt(INT_TA1_0);
MAP_Timer_A_startCounter(TIMER_A1_BASE, TIMER_A_UP_MODE);
/* Enabling MASTER interrupts */
MAP_Interrupt_enableMaster();
/* Sleeping when not in use */
while (1)
{
u1++;
if(u1%2000==0)
//UART_transmitData(EUSCI_A1_BASE, u1);
MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P2, GPIO_PIN0);
}
}
void TA1_0_IRQHandler(void)
{ Timer_A_clearInterruptFlag(TIMER_A1_BASE);
MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
MAP_Timer_A_clearCaptureCompareInterrupt(TIMER_A1_BASE,TIMER_A_CAPTURECOMPARE_REGISTER_0);
}
按键中断正常返回主函数继续执行,目前测试了串口中断和定时器中断都不行
Susan Yang:
您把 Timer_A_clearInterruptFlag(TIMER_A1_BASE); 去掉试试
gaoyang9992006:
参考mspware里的例子,然后你的while里不要这么做先,先在中断里弄个变量,每次中断翻转这个变量,然后将这个变量在主函数查询是否变化,如果改变通过一个LED或者串口打印出来,这样才能确定到底执行没有执行返回。我觉得可能是你while循环里写的这个测试方式是有问题的。