LPC2368 UART problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC2368 UART problem

533 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by anburaj on Wed Aug 14 00:35:53 MST 2013
Dear All,
         I'm trying to implement UART transmission based on THRE interrupt.

Operation(from LPC23xx UART sample code): Initially empty flag is set. In Main loop, if empty flag is set, Data Buffer is assigned to U0THR and empty flag is cleared. if THRE interrupt is occurred then empty flag is set in ISR.

Issue is System gets hanging after some time.

Can anyone give some idea to resolve this issue?

Code:

//Main function
main()
{
   UART0TxEmpty  = 1;
   ByteToSend = 0;
   ByteSent = 0;
   while(1)
   {
     if(ByteToSend == 0)
     {
memcpy(DumpBuff,DataBuff,12);
ByteToSend = 12; ByteSent = 0;
     }

     if(UART0TxEmpty)
if(ByteToSend != 0)
{
   UART0TxEmpty = 0;
   U0THR = DumpBuff[ByteSent++];
   if(ByteSent >= ByteToSend)
   {
ByteToSend = 0;
ByteSent = 0;
   }

}

   }
}

//ISR
irq void UART0_IRQHandler (void)
{
unsigned char IIRValue;
unsigned char LSRValue;


IENABLE;/* handles nested interrupt */
IIRValue = U0IIR;
IIRValue >>= SKIP_IIR_BIT;/* skip pending bit in IIR */
IIRValue &= INT_IDENTIFICATION;/* check bit 1~3, interrupt identification */

if(IIRValue == IIR_THRE)
{
LSRValue = U0LSR;

if(LSRValue & LSR_THRE)
{
UART0TxEmpty = 1;
}
else
{
UART0TxEmpty = 0;
}

}
IDISABLE;
VICVectAddr = 0;//ACK_INTERRUPT;
}




Labels (1)
0 Kudos
2 Replies

335 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MarcVonWindscooting on Mon Aug 19 07:33:46 MST 2013
Albert Einstein once said something similar like this: "if you can't explain it easily, you haven't understood it."

You noticed, nobody replied. That's because your code is a mess.
Tidy that up!
Express what you need. Why would you use ">>=" ? To get confused about the location of the bits THRE/TEMT? Well done.
I have the impression, you have not
well understood bit masks. Check your C knowledge in this area.

Try a program WITHOUT interrupts first. If that works, go ahead with something more difficult.
Understand UART. Then understand VIC. Then combine.
You don't do the second step before the first, when you walk, do you?
0 Kudos

335 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by anburaj on Sun Aug 18 22:56:00 MST 2013
Dear All,
* For transmission status THRE and TEMT status is given in LSR register.
* Whether continuous polling of TEMT (Transmitter empty) cause any system operation ?
* When to use THRE and TEMT ?

0 Kudos