为什么程序在RTC中断服务程序里跳不出来,主函数中的while(1)中的语句总也得不到执行!程序如下!
while(1){
//Set all P1 pins HI
GPIO_setOutputHighOnPin(
__MSP430_BASEADDRESS_PORT5_R__,
GPIO_PORT_P5,
GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 + GPIO_PIN3 +
GPIO_PIN4 + GPIO_PIN5 + GPIO_PIN6 + GPIO_PIN7
);
__delay_cycles(1000000);
GPIO_setOutputLowOnPin(
__MSP430_BASEADDRESS_PORT5_R__,
GPIO_PORT_P5,
GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 + GPIO_PIN3 +
GPIO_PIN4 + GPIO_PIN5 + GPIO_PIN6 + GPIO_PIN7
);
/* if(flag==1)
{
flag=0;
Send_Hex_1(newTime.Year>>8) ; delay();delay();
Send_Hex_1(newTime.Year) ; delay();delay();
Send_Hex_1(newTime.Month) ; delay();delay();
Send_Hex_1(newTime.DayOfMonth); delay();delay();
Send_Hex_1(newTime.DayOfWeek) ; delay();delay();
Send_Hex_1(newTime.Hours) ; delay();delay();
Send_Hex_1(newTime.Minutes) ;
__delay_cycles(1000000);
}*/
//Enter LPM3, interrupts enabled
__bis_SR_register(LPM3_bits + GIE);
__no_operation();
}
#pragma vector=RTC_VECTOR
__interrupt void RTC_ISR (void)
{
switch (__even_in_range(RTCIV,16)){
case 0: break; //No interrupts
case 2: //RTCRDYIFG Read Ready Interrupt flag
//Toggle P1.0 every second
GPIO_toggleOutputOnPin(__MSP430_BASEADDRESS_PORT1_R__,
GPIO_PORT_P1,
GPIO_PIN0);
break;
case 4: //RTCEVIFG time event interrupt enable
//Interrupts every minute
__no_operation();
//Read out New Time a Minute Later BREAKPOINT HERE
newTime = RTC_getCalendarTime(__MSP430_BASEADDRESS_RTC__);
Send_Hex_1(newTime.Year>>8) ; delay();delay();
Send_Hex_1(newTime.Year) ; delay();delay();
Send_Hex_1(newTime.Month) ; delay();delay();
Send_Hex_1(newTime.DayOfMonth); delay();delay();
Send_Hex_1(newTime.DayOfWeek) ; delay();delay();
Send_Hex_1(newTime.Hours) ; delay();delay();
Send_Hex_1(newTime.Minutes) ;
break;
case 6: //RTCAIFG clock alarm interrupt flag
//Interrupts 5:00pm on 5th day of week
// __no_operation();
break;
case 8: break; //RT0PSIFG
case 10: break; //RT1PSIFG
case 12: break; //Reserved
case 14: break; //Reserved
case 16: break; //Reserved
default: break;
}
}
Young Hu:
yonghui zhao
您好!
在while(1)之前有没有让MCU进入低功耗的操作?
在ISR中加入 __bic_SR_register_on_exit(LPM3_bits); // Exit LPM3,
再试试。