总的声明函数:
void BSP_Init(void)
{
CS_INIT();
GPIO_INIT();
//SPI_INIT();
//UART_A0_INIT();
//UART_A1_INIT();
Timer1_A0_Init();
Timer1_A1_Init();
__enable_interrupt();
GPRS_PowerOn(1);
GPS_PowerOn(0);
PC_Sendstring((u8*)":Welcome to the Location app!\r");
// PC_Sendstring((u8*)": By chen ru jun!\r");
}
定时器A0的串口声明:
void UART_A0_INIT(void)
{
EUSCI_A_UART_initParam UART_A0_INIT_PARAM={0};
UART_A0_INIT_PARAM.selectClockSource=EUSCI_A_UART_CLOCKSOURCE_SMCLK;
UART_A0_INIT_PARAM.clockPrescalar=4;
UART_A0_INIT_PARAM.firstModReg=5;
UART_A0_INIT_PARAM.secondModReg=85;
UART_A0_INIT_PARAM.parity=EUSCI_A_UART_NO_PARITY;
UART_A0_INIT_PARAM.msborLsbFirst=EUSCI_A_UART_LSB_FIRST;
UART_A0_INIT_PARAM.numberofStopBits=EUSCI_A_UART_ONE_STOP_BIT;
UART_A0_INIT_PARAM.uartMode=EUSCI_A_UART_MODE;
UART_A0_INIT_PARAM.overSampling=1 ;
if(STATUS_FAIL==EUSCI_A_UART_init(EUSCI_A0_BASE,&UART_A0_INIT_PARAM))
{
return;
}
EUSCI_A_UART_enable(EUSCI_A0_BASE);
/* set deglitch time */
EUSCI_A_UART_selectDeglitchTime(EUSCI_A0_BASE, EUSCI_A_UART_DEGLITCH_TIME_2ns);
EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE,EUSCI_A_UART_RECEIVE_INTERRUPT);
}
定时器A1的串口说明:
void UART_A1_INIT(void)
{
EUSCI_A_UART_initParam UART_A1_INIT_PARAM={0};
UART_A1_INIT_PARAM.selectClockSource=EUSCI_A_UART_CLOCKSOURCE_SMCLK;
UART_A1_INIT_PARAM.clockPrescalar=52;
UART_A1_INIT_PARAM.firstModReg=1;
UART_A1_INIT_PARAM.secondModReg=73;
UART_A1_INIT_PARAM.parity=EUSCI_A_UART_NO_PARITY;
UART_A1_INIT_PARAM.msborLsbFirst=EUSCI_A_UART_LSB_FIRST;
UART_A1_INIT_PARAM.numberofStopBits=EUSCI_A_UART_ONE_STOP_BIT;
UART_A1_INIT_PARAM.uartMode=EUSCI_A_UART_MODE;
UART_A1_INIT_PARAM.overSampling=1 ;
if(STATUS_FAIL==EUSCI_A_UART_init(EUSCI_A1_BASE,&UART_A1_INIT_PARAM))
{
return;
}
EUSCI_A_UART_enable(EUSCI_A1_BASE);
/* set deglitch time */
EUSCI_A_UART_selectDeglitchTime(EUSCI_A1_BASE, EUSCI_A_UART_DEGLITCH_TIME_2ns);
EUSCI_A_UART_enableInterrupt(EUSCI_A1_BASE,EUSCI_A_UART_RECEIVE_INTERRUPT);
//__enable_interrupt();
}
定时器A0的串口中断:
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
{
Tim1_A0_stor.time_count++;
Tim1_A0_stor.time_over_flag=1;
Timer_A_clearTimerInterrupt(TIMER_A0_BASE);
}
定时器A1的串口中断:
#pragma vector=TIMER1_A1_VECTOR
__interrupt void TIMER1_A1_ISR(void)
{
Tim1_A1_stor.time_count++;
Tim1_A1_stor.time_over_flag=1;
Timer_A_clearTimerInterrupt(TIMER_A1_BASE);
}
我在调试的时候,同时用定时器A0 和定时器A1,不知道调试时为什么会一直进入到isr_trap.asm文件中。
我知道这个可能是程序中开了某些中断,但是后面却没有中断处理函数造成的,但是我程序中是有中断处理函数的。所以请大家指导一下,是哪里会有问题呢。
Maka Luo:
把完整程序贴上来,检查你GPIO是否开了中断以及TIMER1是不是误配成TIMER0了。
rujun chen:
回复 Maka Luo:
请问你说的GPIO口开了中断是什么意思?是在GPIO初始化的时候开了中断吗?