[Resolvido]UART travando micro

Software e Hardware para linha ARM

Moderadores: 51, guest2003, Renie, gpenga

[Resolvido]UART travando micro

Mensagempor jonowsky » 08 Jun 2011 10:53

Buenas,

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...
Editado pela última vez por jonowsky em 09 Jun 2011 11:20, em um total de 1 vez.
Avatar do usuário
jonowsky
Byte
 
Mensagens: 148
Registrado em: 26 Mai 2009 15:18
Localização: Rio Grande do Sul

Re: UART travando micro

Mensagempor andre_luis » 08 Jun 2011 18:40

Palpite :

Coloca alguma rotina para debugar se esta ocorrendo estouro da fila de recepção como abaixo.

Código: Selecionar todos
      if ( UART1Count == BUFSIZE )
      {
          //    AQUI NESSE PONTO  //
          UART1Count = 0;      /* buffer overflow */
      }


+++
"Por maior que seja o buraco em que você se encontra, relaxe, porque ainda não há terra em cima."
Avatar do usuário
andre_luis
Dword
 
Mensagens: 5447
Registrado em: 11 Out 2006 18:27
Localização: Brasil - RJ

Re: UART travando micro

Mensagempor Rodrigo_P_A » 08 Jun 2011 19:49

jonowsky escreveu:Buenas,

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...


pq vc está habilitando a interrupção dentro da interrupção?
---
Avatar do usuário
Rodrigo_P_A
Dword
 
Mensagens: 2237
Registrado em: 12 Out 2006 18:27
Localização: Osasco - S.P - Brasil

Re: UART travando micro

Mensagempor jonowsky » 09 Jun 2011 11:19

Rodrigo_P_A escreveu:
jonowsky escreveu:Buenas,

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...


pq vc está habilitando a interrupção dentro da interrupção?



Bingo!!!

Retirei a parte que habilita a interrupção e o bixinho parou de travar!

te devo (mais) essa Rodrigo!
Avatar do usuário
jonowsky
Byte
 
Mensagens: 148
Registrado em: 26 Mai 2009 15:18
Localização: Rio Grande do Sul


Voltar para ARM

Quem está online

Usuários navegando neste fórum: Google [Bot] e 1 visitante

x