LPC1857 USART problem

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

LPC1857 USART problem

Jump to solution
945 Views
andrewbarningha
Contributor III

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*/
     }
}

1 Solution
602 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Andrew,

Have you tried using the periph_uart example that comes with the LPCOpen package? This example shows how to use the UART in polling, interrupt and DMA mode. You can download the LPCOpen package for the Keil MCB1800 (LPC1857) board from this link:

LPCOpen Software for LPC18XX|NXP 

Hope it helps!

Best Regards,
Carlos Mendoza
Technical Support Engineer

View solution in original post

0 Kudos
Reply
2 Replies
603 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Andrew,

Have you tried using the periph_uart example that comes with the LPCOpen package? This example shows how to use the UART in polling, interrupt and DMA mode. You can download the LPCOpen package for the Keil MCB1800 (LPC1857) board from this link:

LPCOpen Software for LPC18XX|NXP 

Hope it helps!

Best Regards,
Carlos Mendoza
Technical Support Engineer

0 Kudos
Reply
602 Views
andrewbarningha
Contributor III

Thanks Carlos,

I now have the USART working, i had the pin multiplexing setup wrong, so i changed the settings to below and it now works.

/*set pins up for USART 0 */
 LPC_SCU->SFSP2_0 = 0x09; /* Function 1..U0_TXD, enable pull down. */
 LPC_SCU->SFSP2_1 = 0xC1; /* Function 1..U0_RXD, Enable input buffer, Disable glitch filter*/

I will look at the link you sent me for a deeper understanding of the USART.

Thanks

Andrew