Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LPC2138 UART irq problem

Status
Not open for further replies.

akshada

Member level 3
Joined
Jun 29, 2010
Messages
67
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
india
Activity points
1,746
I m trying to configure my UART irq but for some reason it is not working.I've tested my UART without IRQ and was working fine.



Code:
void UARTInit(unsigned long baudrate)
{
  	volatile char dummy;
	unsigned long Fdiv;
	PCONP |= (1<<4); 
	PINSEL0 |= 0x00050000;
   	
	U1LCR = 0x83;                        /* DLAB =1, STOP =1, NO PARIY, WORD LENGTH = 8 */
	
	Fdiv = ( 15000000UL / 16 ) / baudrate ;	 /* baud rate */
	U1DLM = Fdiv / 256;							
        U1DLL = Fdiv % 256;	
        U1LCR = 0x03;                                                    /* DLAB = 0 */
        U1FCR = 0x07;		                                       /* Enable and reset TX and RX FIFO. */

        VICVectAddr7 = (unsigned long)UART1Handler;          /* set interrupt vector 2 to UART0_IRQHandler interrupt function*/
	VICVectCntl7 = (0x20 | 7);                                    /* enable slot & use it for UART0 Interrupt */
	VICIntEnable |= (unsigned long)(1<<7);                   /* Enable UART0 Interrupt */

  	dummy = U1IIR;                                                   /* Read IrqID - Required to Get Interrupts Started */

	U0IER = IER_RBR | IER_THRE | IER_RLS;	                /* Enable UART0 interrupt */
}



__irq void UART1Handler (void)  
{
  unsigned char IIRValue, LSRValue;

  IIRValue = U1IIR;
    
  IIRValue >>= 1;			/* skip pending bit in IIR */
  IIRValue &= 0x07;			/* check bit 1~3, interrupt identification */

  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 )	 // if(transmitter empty)
	{
	  UART1TxEmpty = 1;		  //empty
	}
	else
	{
	  UART1TxEmpty = 0;		  //char  available
	}
  }
  VICVectAddr = 0;		/* Acknowledge Interrupt */
}



void UARTSend( unsigned char *BufferPtr)
{

	while (*BufferPtr)
    {
	  
	  while ( !(UART1TxEmpty & 0x01) );	/*THRE status, contain valid data */
	  U1THR = *BufferPtr;
	  UART1TxEmpty = 0;	                        /*not empty in the THR until it shifts out */
	  BufferPtr++;
    }
}
thanks in advance.......
 

actually i am not able to run my code in proteus with irq on.
 

nobody has faced such type of problem yet?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top