我想从430的串口向PC机发送时间数据,但是程序在中RTC的中断服务程序里跳不出来,在主函数中的程序无法执行,请问是什么问题,急!
#include "zyh.h"
unsigned char flag=0;
unsigned int status;
Calendar newTime;
void main (void)
{
unsigned char i,*p;
Calendar currentTime;
//Setup Current Time for Calendar
currentTime.Seconds = 0x00;
currentTime.Minutes = 0x08;
currentTime.Hours = 0x12;
currentTime.DayOfWeek = 0x07;
currentTime.DayOfMonth = 0x11;
currentTime.Month = 0x03;
currentTime.Year = 0x2012;
//Stop WDT
WDT_hold(__MSP430_BASEADDRESS_WDT_A__);
Sys_Clock_Init(); //系统时钟初始化
Serial_1_Init(); //串口初始化
RTC_A_Calender_Init(currentTime); //RTC初始?
p=zyh;
while(1){
if(flag==1)
{
flag=0;
Send_Hex_1(newTime.Year>>8) ; delay();delay();//向串口发送时间数据,在PC上显示
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;
}
}
//******************************************************************************
//
//This is the USCI_A0 interrupt vector service routine.
//
//******************************************************************************
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR (void)
{
switch (__even_in_range(UCA0IV,4)){
//Vector 2 – RXIFG
case 2:
//Echo back RXed character, confirm TX buffer is ready first
//USCI_A0 TX buffer ready?
while (!UART_getInterruptStatus(__MSP430_BASEADDRESS_USCI_A0__,
UART_TRANSMIT_INTERRUPT_FLAG)
) ;
//Receive echoed data//将接收到的字符串存到缓存中
Buf_First_Serial[First_Int]= UART_receiveData(__MSP430_BASEADDRESS_USCI_A0__);
First_Int++; //缓存指针向后移动
if(First_Int > Buf1_Max) //如果缓存满,将缓存指针指向缓存的首地址
{
First_Int = 0;
}
break;
default: break;
}
}
/*—————————————————————————–
Fun name :
Parameter:
Descripe :系统时钟设置中断函数
——————————————————————————-*/
#pragma vector=UNMI_VECTOR
__interrupt void NMI_ISR(void)
{
do {
// If it still can't clear the oscillator fault flags after the timeout,
// trap and wait here.
status = UCS_clearAllOscFlagsWithTimeout(__MSP430_BASEADDRESS_UCS__,
1000
);
} while(status != 0);
}
Young Hu:
yonghui zhao,
您好!
在ISR中加入 __bic_SR_register_on_exit(LPM3_bits); // Exit LPM3,
再试试。