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.

Tms320C5505 UART Interrupt

Other Parts Discussed in Thread: TMS320C5505

Hi

I have already installed UART module. The Tx part of module is set to work in the form of polling and I don't have any problem with that.
but I face with a problem in RX part which is set to work with interrupt.
Following is the code that I have written for the interrupt routine.

interrupt void UART_intrDispatch(void)
{
 register unsigned char i;
 Uint16 eventId = 0;

 asm(" BCLR INTM ");

 eventId = CSL_FEXT(CSL_UART_REGS->IIR,UART_IIR_INTID);

 switch (eventId)
 {
  case UART_EVT_RBI_IID:
  case UART_EVT_CTOI_IID:
      CSL_UART_REGS->LCR &= ~CSL_UART_LCR_DLAB_MASK;
   
   while(CSL_UART_REGS->LSR & CSL_UART_LSR_DR_MASK)
   {
       RxS_Buf[RxS_Wrp] = CSL_UART_REGS->RBR;
    RxS_Wrp++;
    RxS_Wrp &= SCI_MASK;
    RxS_Cnt++;
   }
   
   break;
  case UART_EVT_TBEI_IID:
   break;
  case UART_EVT_LSI_IID:
   i = CSL_UART_REGS->LSR;
   i = i;
   break;
 }

 return;
}

And Here is my UART Setup :

oid UartInit(void)
{
 TxS_Act = TxS_Rdp = TxS_Wrp = TxS_Cnt = 0;
 RxS_Rdp = RxS_Wrp = RxS_Cnt = RxS_Chk = 0;

 SystemClk = 98304000;

    /**Enable Master clock                                     */
    CSL_FINST(CSL_SYSCTRL_REGS->PCGCR1,SYS_PCGCR1_SYSCLKDIS,ACTIVE);
    /**Enable uart peripheral clock gating                  */
    CSL_FINST(CSL_SYSCTRL_REGS->PCGCR1,SYS_PCGCR1_UARTCG,ACTIVE);

    /* Configure UART registers using setup structure */
    Uart_setup();

 /* Configuring Interrupt */
 IRQ_plug (UART_EVENT, &UART_intrDispatch);

 /* Enabling Interrupt */
 IRQ_enable(UART_EVENT);

  /* Enable the UART Events */
    CSL_FINST(CSL_UART_REGS->LCR, UART_LCR_DLAB, DLABON);

    CSL_FINST(CSL_UART_REGS->IER, UART_IER_ERBI,ENABLE);
   
//    CSL_FINST(CSL_UART_REGS->IER,UART_IER_ETBEI,ENABLE);
   
    CSL_FINST(CSL_UART_REGS->IER,UART_IER_ELSI,ENABLE);
}
//*****************************************************************************
void Uart_setup(void)
{
  Uint32 value;
  Uint32 clk_div;

     /**Putting UART recvor and xmittor in reset state*/
    CSL_UART_REGS->PWREMU_MGMT = CSL_UART_PWREMU_MGMT_RESETVAL;
 /* Write 0 to DLAB to access IER*/
 CSL_FINST(CSL_UART_REGS->LCR, UART_LCR_DLAB, DLABON);
 /*Disable all interrupts*/
 CSL_UART_REGS->IER = CSL_UART_IER_RESETVAL;
 /* Flushing buffer */
    value = (Uint32)(CSL_UART_REGS->RBR);
     /* reset and possibly enable FIFOs */
    CSL_FINST(CSL_UART_REGS->FCR, UART_FCR_FIFOEN, ENABLE);
 CSL_FINST(CSL_UART_REGS->FCR, UART_FCR_RXCLR, CLR);
 CSL_FINST(CSL_UART_REGS->FCR, UART_FCR_TXCLR, CLR);
 CSL_UART_REGS->FCR = CSL_UART_FIFO_DMA1_DISABLE_TRIG08; 
 clk_div = CSL_UART_CLK_DIVIDER(115200);

 /* Set DLL and DLM to values appropriate for the required baudrate */
 value = ( (Uint32) (SystemClk) / (clk_div ) );

 /* Write 1 to DLAB to access DLL and DLH*/
 CSL_FINST(CSL_UART_REGS->LCR, UART_LCR_DLAB, DLABOFF);

 if ( ( (Uint32)(SystemClk) % ( clk_div ) )
        >=   ( clk_div / 2 ) )
    {
  if ((value & 0xFF)  != 0xFF)
  {
            CSL_UART_REGS->DLL = (Uint8)(value & 0xFF) + 1;
            CSL_UART_REGS->DLH = (Uint8)((value & 0xFF00) >> 8);
        }
  else
  {
            CSL_UART_REGS->DLL = (Uint8) ( 0x00 );
            CSL_UART_REGS->DLH = (Uint8) ( ( ( value & 0xFF00 ) >> 8 ) + 0x1u );
        }

    }
 else
 {
  CSL_UART_REGS->DLL = (Uint8)(value & 0xFF) ;
        CSL_UART_REGS->DLH = (Uint8)((value & 0xFF00) >> 8);
 }

 CSL_FINST(CSL_UART_REGS->LCR, UART_LCR_DLAB,DLABON);
    /*setup word size*/
    CSL_FINST(CSL_UART_REGS->LCR,UART_LCR_WLS,BITS8);

    /*  Stop bits generation */            
    CSL_FINS(CSL_UART_REGS->LCR,UART_LCR_STB,0);  // /* 0 To generate 1 stop bit */

    /* Parity selection */ 
    CSL_FINST(CSL_UART_REGS->LCR,UART_LCR_PEN,DISABLE);

    /* setup loopback control */
 CSL_FINST(CSL_UART_REGS->MCR,UART_MCR_LOOP,DISABLE);

 CSL_FINST(CSL_UART_REGS->MCR,UART_MCR_AFE,DISABLE);

 CSL_FINST(CSL_UART_REGS->MCR,UART_MCR_RTS,CTSEN);

 /* UART Receiver enabled */  
    CSL_FINST(CSL_UART_REGS->PWREMU_MGMT,UART_PWREMU_MGMT_URRST,ENABLE);
 /* UART Transmitter enabled */
 CSL_FINST(CSL_UART_REGS->PWREMU_MGMT,UART_PWREMU_MGMT_UTRST,ENABLE);

    CSL_FINST(CSL_UART_REGS->PWREMU_MGMT,UART_PWREMU_MGMT_FREE,RUN);
}
//*****************************************************************************


It is noteworthy that the mentioned interrupt will be stoped after a short time working.
I request you kindly help me & give me a solution in order to solve this problem.
I would greatly appreciate your cooperation.
Look forward to receiving your favorite answer very soon.


Yours Truly,

A.Ghorbanian

  • Hi Ali,

    Sorry for the delay in responding. We will inspect your code next week and let you know what we find.

    Are you using the EVM, eZdsp, custom board? I am curious about the UART module you are using. Is it the RS232 connection?

    Best Regards,
    Mark 

  • Hi Mark,

    I am very grateful for your response.

    For your information let me mention that we are using a custom board and as the above picture depicts in our design no RS232 exists and we have connected UART directly to an ARM microcontroller.

    I am impatiently looking forward to hearing from you soon,

    Best regards,

    Ali

  • Hi Mark,

    As you might remember I sent you an email asking for a solution for the unexpected stop of UART interrupt in TMS320c5505. Since two weeks has been passed from the day I sent my email and I haven't still got any response from you, it would be my pleasure if you inform me about any possible solution that you might have found.

    I am impatiently looking forward to hearing from you soon,

    Best regards,

    Ali