AnsweredAssumed Answered

LPC1857 USART problem

Question asked by Andrew Barningham on Jan 20, 2017
Latest reply on Feb 1, 2017 by Andrew Barningham

Hi,

Is anyone able to help me. I am new to the LPC1857 chip.

 

I am using the MCB1857 development board and i want to use USART3.

I can send data from the controller by simple doing the below after setting the USART up.

   LPC_USART3->THR = 'A'

 

But i am unable to get the USART3 interrupt to trigger on a send or receive char, in debug it will NOT jump into the interrupt function at all. See below my code... have i missed anything?

 

/*prototype*/

__irq void UART3_IRQHandler (void);

 

/**************** SET UP USART 3 *************************************/
LPC_SCU->SFSP2_3 = 0x02;
LPC_SCU->SFSP2_4 = 0x02;

LPC_USART3->LCR = 0x83; /*line control register.. stop, data bits etc.... 8 data bits, 1stop bit, NO parity*/
LPC_USART3->FDR = 0; /*fractional divide*/
LPC_USART3->DLL = 78; /*divide latch LSB... 9600 baud*/
LPC_USART3->DLM = 0; /*divide latch MSB*/
LPC_USART3->LCR = 0x03; /* disable DLAB*/
LPC_USART3->FCR = 0x07; /*Fifo buffer*/
LPC_USART3->IER = 0x01; /*enable interupt*/

NVIC_SetPriority(USART3_IRQn, 1);
NVIC_EnableIRQ(USART3_IRQn); /*enable USART3 interupt*/

 

/********************************************************************************/
/* ####### USART interupt function ########################## */
/********************************************************************************/
__irq void UART3_IRQHandler(void)
{
unsigned short ushLocalVar = 0;

   /*recieving a byte*/
   if(LPC_USART3->LSR & 0x01)
   {
   ushLocalVar = LPC_USART3->RBR;
   }

   if((ushLocalVar == 'A') || (ushLocalVar == 'a'))
   {
    /*transmit a byte*/
         if(LPC_USART3->LSR & 0x20)
         {
         LPC_USART3->THR = 'K';
        }
    }
     else
     {
      LPC_USART3->IER = 0x01; /*re-enable interupt*/
     }
}

Outcomes