|
我用的430 f149 串口中断进不去咋办void Uart_Init(void)
{
P3SEL |= 0x30; // 选择P3.4和P3.5做UART通信端口
P3DIR = 0x10;
UCTL0|= SWRST; //开始设置串口
ME1 |= URXE0; // 使能USART0的发送和接受
U0CTL |= CHAR; // 选择8位字
UTCTL0 |= SSEL0; //选择模块时钟源 ; // UCLK = ACLK
UBR00 = 0x06; // 波特率4800
UBR10 = 0x00; //
UMCTL0 = 0xFB; // Modulation
UCTL0 &= ~SWRST; //设置串口 完毕
IE1 |= URXIE0;
}
#pragma vector=UART0RX_VECTOR
__interrupt void usart0_rx (void)
{
char ch;
IE1 &= ~URXIE0; //ES = 0;_DINT();
if((IFG1 & URXIFG0))
{
ch = RXBUF0;
if ((ch == '$') && (gps_flag == 0)) //如果收到字符'$',便开始接收
{
rev_start = 1;
rev_stop = 0;
}
rev_start = 1;
if (rev_start == 1) //标志位为1,开始接收
{
rev_buf[num++] =ch; //字符存到数组中
if (ch== '\n') //如果接收到换行
{
rev_buf[num] = '\0';
rev_start = 0;
rev_stop = 1;
gps_flag = 1;
num = 0;
}
}
}
IFG1&=~URXIFG0;
IE1 |= URXIE0; // _EINT();
} |
|