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.

TMS320C6657 UART 不能发生中断



现在使用的EVM6657开发板,现在可以通过轮询的方式读写串口0,现在想改成中断模式,但中断始终不能产生,用的开发板引出的串口0,串口初始化程序如下:

void UartInit(void)
{
// Allows access to the divisor latches of the baud generator during a
// read or write operation (DLL and DLH)
CSL_FINS (hUartRegs->LCR, UART_LCR_DLAB, CSL_UART_LCR_DLAB_ENABLE);
CSL_FINS (hUartRegs_B->LCR, UART_LCR_DLAB, CSL_UART_LCR_DLAB_ENABLE);

// Break condition is disabled.
CSL_FINS (hUartRegs->LCR, UART_LCR_BC, CSL_UART_LCR_BC_DISABLE);
CSL_FINS (hUartRegs_B->LCR, UART_LCR_BC, CSL_UART_LCR_BC_DISABLE);

// Stick parity is disabled.
CSL_FINS (hUartRegs->LCR, UART_LCR_SP, CSL_UART_LCR_SP_DISABLE);
CSL_FINS (hUartRegs_B->LCR, UART_LCR_SP, CSL_UART_LCR_SP_DISABLE);

// Odd parity is selected
CSL_FINS (hUartRegs->LCR, UART_LCR_EPS, CSL_UART_LCR_EPS_ODD);
CSL_FINS (hUartRegs_B->LCR, UART_LCR_EPS, CSL_UART_LCR_EPS_ODD);

// No PARITY bit is transmitted or checked
CSL_FINS (hUartRegs->LCR, UART_LCR_PEN, CSL_UART_LCR_PEN_DISABLE);
CSL_FINS (hUartRegs_B->LCR, UART_LCR_PEN, CSL_UART_LCR_PEN_DISABLE);


// Set the baudrate,for accessing LCR[7] should be enable
hUartRegs->DLL = DLL_VAL;
hUartRegs_B->DLL = DLL_VAL;

hUartRegs->DLH = DLM_VAL;
hUartRegs_B->DLH = DLM_VAL;


// Allows access to the receiver buffer register (RBR),
// the transmitter holding register (THR), and the
// interrupt enable register (IER) selected.
CSL_FINS (hUartRegs->LCR, UART_LCR_DLAB, CSL_UART_LCR_DLAB_DISABLE);
CSL_FINS (hUartRegs_B->LCR, UART_LCR_DLAB, CSL_UART_LCR_DLAB_DISABLE);

// Even Parity is selected
CSL_FINS (hUartRegs->LCR, UART_LCR_EPS, CSL_UART_LCR_EPS_EVEN);
CSL_FINS (hUartRegs_B->LCR, UART_LCR_EPS, CSL_UART_LCR_EPS_EVEN);

// Parity Enable
CSL_FINS (hUartRegs->LCR, UART_LCR_PEN, CSL_UART_LCR_PEN_ENABLE);
CSL_FINS (hUartRegs_B->LCR, UART_LCR_PEN, CSL_UART_LCR_PEN_ENABLE);


// Disable THR, RHR, Receiver line status interrupts
//modify by micheal 20131126
CSL_FINS (hUartRegs->IER, UART_IER_ERBI, CSL_UART_IER_ERBI_ENABLE);
CSL_FINS (hUartRegs->IER, UART_IER_ETBEI, CSL_UART_IER_ETBEI_ENABLE);
CSL_FINS (hUartRegs->IER, UART_IER_ELSI, CSL_UART_IER_ELSI_ENABLE);
CSL_FINS (hUartRegs->IER, UART_IER_EDSSI, CSL_UART_IER_EDSSI_ENABLE);
//modify by mcheal 20131126
CSL_FINS (hUartRegs_B->IER, UART_IER_ERBI, CSL_UART_IER_ERBI_DISABLE);
CSL_FINS (hUartRegs_B->IER, UART_IER_ETBEI, CSL_UART_IER_ETBEI_DISABLE);
CSL_FINS (hUartRegs_B->IER, UART_IER_ELSI, CSL_UART_IER_ELSI_DISABLE);
CSL_FINS (hUartRegs_B->IER, UART_IER_EDSSI, CSL_UART_IER_EDSSI_DISABLE);

/* If autoflow control is desired,
* write appropriate values to the modem
* control register (MCR). Note that all UARTs
* do not support autoflow control, see
* the device-specific data manual for supported features.
*
* MCR
* ====================================================
* Bit Field Value Description
* 5 AFE 0 Autoflow control is disabled
* 4 LOOP 0 Loop back mode is disabled.
* 1 RTS 0 RTS control (UARTn_RTS is disabled,
* UARTn_CTS is only enabled.)
* =====================================================
*
*
*/

hUartRegs->MCR = 0;
hUartRegs_B->MCR = 0;

/* Choose the desired response to
* emulation suspend events by configuring
* the FREE bit and enable the UART by setting
* the UTRST and URRST bits in the power and
* emulation management register (PWREMU_MGMT).
*
*
* PWREMU_MGMT
* =================================================
* Bit Field Value Description
* 14 UTRST 1 Transmitter is enabled
* 13 URRST 1 Receiver is enabled
* 0 FREE 1 Free-running mode is enabled
* ===================================================
*
*/
hUartRegs->PWREMU_MGMT = 0x6001;
hUartRegs_B->PWREMU_MGMT = 0x6001;


/* Cleanup previous data (rx trigger is also set to 0)*/
/* Set FCR = 0x07; */
CSL_FINS (hUartRegs->FCR, UART_FCR_FIFOEN, CSL_UART_FCR_FIFOEN_ENABLE);
CSL_FINS (hUartRegs->FCR, UART_FCR_TXCLR, CSL_UART_FCR_TXCLR_CLR);
CSL_FINS (hUartRegs->FCR, UART_FCR_RXCLR, CSL_UART_FCR_RXCLR_CLR);
CSL_FINS (hUartRegs->FCR, UART_FCR_DMAMODE1, CSL_UART_FCR_DMAMODE1_ENABLE);
//modify by mcheal 20131126
CSL_FINS (hUartRegs->FCR, UART_FCR_RXFIFTL, CSL_UART_FCR_RXFIFTL_CHAR14);


/* Cleanup previous data (rx trigger is also set to 0)*/
/* Set FCR = 0x07; */
CSL_FINS (hUartRegs_B->FCR, UART_FCR_FIFOEN, CSL_UART_FCR_FIFOEN_ENABLE);
CSL_FINS (hUartRegs_B->FCR, UART_FCR_TXCLR, CSL_UART_FCR_TXCLR_CLR);
CSL_FINS (hUartRegs_B->FCR, UART_FCR_RXCLR, CSL_UART_FCR_RXCLR_CLR);
CSL_FINS (hUartRegs_B->FCR, UART_FCR_DMAMODE1, CSL_UART_FCR_DMAMODE1_DISABLE);
//modify by mcheal 20131126
CSL_FINS (hUartRegs_B->FCR, UART_FCR_RXFIFTL, CSL_UART_FCR_RXFIFTL_CHAR14);

return;
}

mian函数如下:

Void main()
{
Task_Handle task;
Error_Block eb;

int eventId;
Hwi_Params params;

System_printf("enter main()\n");
//
CpIntc_mapSysIntToHostInt(0, 164, 42);

CpIntc_dispatchPlug(164, (CpIntc_FuncPtr)&myTxint, 164, TRUE);

CpIntc_enableHostInt(0, 42);

eventId = CpIntc_getEventId(42);

Hwi_Params_init(&params);

params.arg = 42;

params.eventId = eventId;

params.enableInt = TRUE;

params.priority = 2;

Hwi_create(9, &CpIntc_dispatch, &params, NULL);

Hwi_enableInterrupt(9);

Hwi_enable();

BIOS_start(); /* enable interrupts and start SYS/BIOS */
}

中断函数如下:

void myTxint()
{

System_printf("interrupt!");
}

麻烦各位帮忙解决一下,万分感谢!