|
初始化使能了发送空中断,但是程序一直进不去中断是什么问题?
#include "hw_types.h"
#include "soc_C665x.h"
#include "uart.h"
#include "interrupt.h"
#include "cic_event.h"
#include "Board.h"
#define UICIC_OUTNUM 0;
#define CIC0_SYSTEM_EVENT_UART0 164;
DSPType DSPChipType;// DSP 芯片型号
BoardUART uart0cfg;// 串口配置
unsigned int flag=0;
char txArray[]="Hello Word\n\r";
void Delay(volatile unsigned int n)
{
unsigned int i;
for(i = n; i > 0; i--);
}
void PeriphInit()
{
// 串口初始化
uart0cfg.ID = BoardUART0;
uart0cfg.BaudRate = BAUD_115200;
uart0cfg.config = UART_WORDL_8BITS;
uart0cfg.OverSampRate = UART_OVER_SAMP_RATE_16;
UARTInit(&uart0cfg);
UARTIntEnable(SOC_UART_0_REGS,UART_INT_LINE_STAT|UART_INT_TX_EMPTY|UART_INT_RXDATA_CTI);
}
void UARTIsr();
void main(void)
{
DSPChipType = DSPTypeGet();
IntDSPINTCInit();
IntGlobalEnable();
CICDisableGlobalHostInt(SOC_CIC_0_REGS);
CICEventMap(SOC_CIC_0_REGS,164,0);
CICEnableGlobalHostInt(SOC_CIC_0_REGS);
IntEventMap(C66X_MASK_INT4,SYS_INT_CIC0_OUT0_20);
IntRegister(C66X_MASK_INT4,UARTIsr);
IntEnable(C66X_MASK_INT4);
PeriphInit();
while(1);
}
void UARTIsr()
{
static unsigned int length = sizeof(txArray);
static unsigned int count = 0;
unsigned int int_id = 0;
unsigned char rxData=0;
int_id = UARTIntStatus(SOC_UART_0_REGS);
CICClearSystemEvent(SOC_CIC_0_REGS, 164);
if(UART_INTID_TX_EMPTY == int_id)
{
if(0 < length)
{
// 写一个字节到 THR
UARTCharPutNonBlocking(SOC_UART_0_REGS, txArray[count]);
length--;
count++;
}
if(0 == length)
{
// 禁用发送中断
UARTIntDisable(SOC_UART_0_REGS, UART_INT_TX_EMPTY);
}
}
// 接收中断
if(UART_INTID_RX_DATA == int_id)
{
rxData= UARTCharGetNonBlocking(SOC_UART_0_REGS);
UARTCharPutNonBlocking(SOC_UART_0_REGS, rxData);
}
// 接收错误
if(UART_INTID_RX_LINE_STAT == int_id)
{
while(UARTRxErrorGet(SOC_UART_0_REGS))
{
// 从 RBR 读一个字节
UARTCharGetNonBlocking(SOC_UART_0_REGS);
}
}
}
|
|