This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320C6748: C6748

Part Number: TMS320C6748
你好:   
我在调试串口1的FIFO中断模式中,发现串口收发正常工作一段时间后,中断不再能进去。代码的主要想法的接收任意帧长度,或发送任意帧长度的数据。打断点查看此时有Receiver line status中断标志,且中断也开启了。此时




主要代码如下:
void UART1_Send(unsigned char len)
{
int i;
Uart1_TXBuff_Length = len;
Uart1_TXBuff_Count = 0;
if(len <= 16) //串口发送的FIFO长度为16
{
//先关全局中断。防止向FIFO写被打断,然后再打开全局中断
IntGlobalDisable();
//待发送长度小于FIFO长度,一次发送完
for(i=0; i<len; i++)
{
HWREG(SOC_UART_1_REGS + UART_THR) = *(Uart1_TXBuff+i);
}
Uart1_TXBuff_Length = 0;
Uart1_TXBuff_Count = 0;
IntGlobalEnable();
}
else
{
IntGlobalDisable();
//待发送长度大于FIFO长度,先发FIFO长度,发送完后会触发中断,在中断中继续发送
for(i=0; i<16; i++)
{
HWREG(SOC_UART_1_REGS + UART_THR) = *(Uart1_TXBuff+i);
}
Uart1_TXBuff_Length -= 16;
Uart1_TXBuff_Count += 16;
IntGlobalEnable();
}
}
void UART1_Isr(void)
{
unsigned int int_id = 0;
int i;
Core_LED_Blink();
//查中断源,同时读IIR的时候会自动清发送完成中断
    int_id = UARTIntStatus(SOC_UART_1_REGS);
    //清除系统中断
    IntEventClear(SYS_INT_UART1_INT);
    //接收FIFO满或timeout
    if((UART_INTID_RX_DATA == int_id) || (UART_INTID_CTI == int_id))
    {
     //从 FIFO逐个读取字符并输出
     while(HWREG(SOC_UART_1_REGS + UART_LSR) & UART_DATA_READY)
     {
     Uart1_RXBuff[order] = UARTCharGet(SOC_UART_1_REGS);
     order++;
     }
     //数据处理,以最严格的条件处理
if((Uart1_RXBuff[0] != UART1_HEAD_1) || (Uart1_RXBuff[1] != UART1_HEAD_2)) //存在不完整帧
{
order = 0;
}
else
{
if(order == Uart1_RXBuff[2]) //接收到完整一帧
{
order = 0;
Uart1_Rec_Flag = 1;
//保存一帧数据,校验等放在主程序中
//memcpy(Uart1_RXData,Uart1_RXBuff,Uart1_RXBuff[2]);
}
else if (order > Uart1_RXBuff[2]) //数据长度不对
{
order = 0;
}
else
{
//一帧数据未完
}
}
//防止order溢出
if(order >= UART1_RX_MAX_LENGTH)
{
order = 0;
}
    }
    //发送FIFO空中断
    if(UART_INTID_TX_EMPTY == int_id)
    {
     if(Uart1_TXBuff_Length != 0)
     {
     if(Uart1_TXBuff_Length <= 16) //串口发送的FIFO长度为16
     {
     //待发送长度小于FIFO长度,一次发送完
     for(i=0; i<Uart1_TXBuff_Length; i++)
     {
     HWREG(SOC_UART_1_REGS + UART_THR) = *(Uart1_TXBuff+Uart1_TXBuff_Count+i);
     }
     Uart1_TXBuff_Length = 0;
     Uart1_TXBuff_Count = 0;
     }
     else
     {
     //待发送长度大于FIFO长度,先发FIFO长度,发送完后会触发中断,在中断中继续发送
     for(i=0; i<16; i++)
     {
     HWREG(SOC_UART_1_REGS + UART_THR) = *(Uart1_TXBuff+Uart1_TXBuff_Count+i);
     }
     Uart1_TXBuff_Length -= 16;
     Uart1_TXBuff_Count += 16;
     }
     }
     else
     {
     //上电会进入一次
     }
    }
    // 接收错误
    if(UART_INTID_RX_LINE_STAT == int_id)
    {
        while(UARTRxErrorGet(SOC_UART_1_REGS))
        {
            UARTCharGetNonBlocking(SOC_UART_1_REGS);//从 RBR 读一个字节
        }
    }
}
期待答疑,谢谢。