Estou utilizando o exemplo fornecido pela Keil para trabalhar com a interrupção UART no LPC2368, o que acontece é que possuo uma aplicação onde o LPC2368 fica trocando informações constantemente com um PC. Aleatóriamente o LPC simplesmente trava e só volta a funcionar resetando-o.
Muitas vezes ele fica horas trabalhando e do nada, sem nehuma intervenção ele trava! abaixo segue o código da interrupção:
- Código: Selecionar todos
void InterupcaoUART1 (void) __irq
{
BYTE IIRValue, LSRValue;
BYTE Dummy;
IENABLE;
IIRValue = U1IIR;
IIRValue >>= 1; /* skip pending bit in IIR */
IIRValue &= 0x07; /* check bit 1~3, interrupt identification */
if ( IIRValue == IIR_RLS ) /* Receive Line Status */
{
LSRValue = U1LSR;
/* Receive Line Status */
if ( LSRValue & (LSR_OE|LSR_PE|LSR_FE|LSR_RXFE|LSR_BI) )
{
/* There are errors or break interrupt */
/* Read LSR will clear the interrupt */
UART1Status = LSRValue;
Dummy = U1RBR; /* Dummy read on RX to clear
interrupt, then bail out */
IDISABLE;
VICVectAddr = 0; /* Acknowledge Interrupt */
return;
}
if ( LSRValue & LSR_RDR ) /* Receive Data Ready */
{
/* If no error on RLS, normal ready, save into the data buffer. */
/* Note: read RBR will clear the interrupt */
/*UART1Buffer[UART1Count] = U1RBR;
UART1Count++;
if ( UART1Count == BUFSIZE )
{
UART1Count = 0; // buffer overflow
}*/
}
}
else if ( IIRValue == IIR_RDA ) /* Receive Data Available */
{
/* Receive Data Available */
UART1Buffer[UART1Count] = U1RBR;
UART1Count++;
if ( UART1Count == BUFSIZE )
{
UART1Count = 0; /* buffer overflow */
}
}
else if ( IIRValue == IIR_CTI ) /* Character timeout indicator */
{
/* Character Time-out indicator */
UART1Status |= 0x100; /* Bit 9 as the CTI error */
}
else if ( IIRValue == IIR_THRE ) /* THRE, transmit holding register empty */
{
/* THRE interrupt */
LSRValue = U1LSR; /* Check status in the LSR to see if
valid data in U0THR or not */
if ( LSRValue & LSR_THRE )
{
UART1TxEmpty = 1;
}
else
{
UART1TxEmpty = 0;
}
}
IDISABLE;
VICVectAddr = 0; /* Acknowledge Interrupt */
}
Já fiz testes e desabilitando a UART funciona belezinha...
A alternativa que utilizei até agora foi usar o watchdog, mas gostaria de resolver de vez esse problema...