UART example code with LPC1343

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

UART example code with LPC1343

2,423 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tungsys on Sat Apr 30 12:34:37 MST 2011
Hi every one,

Can any body help me to understand the uart example of lpc1343. The example is simple echo the character you input from teraterm or hyperterminal. But my question is when will the value of variable UARTCount change !=0 ? Seem it is initialized with value 0 and no place in the code change this value.

------------------------------------------------------------------------------------
/*****************************************************************************
*   uarttest.c:  UART test C file for NXP LPC13xx Family Microprocessors
*
*   Copyright(C) 2008, NXP Semiconductor
*   All rights reserved.
*
*   History
*   2008.08.20  ver 1.00    Preliminary version, first Release
*
******************************************************************************/
#include "LPC13xx.h"
#include "uart.h"

extern volatile uint32_t UARTCount;
extern volatile uint8_t UARTBuffer[BUFSIZE];

int main (void) {
      /* Basic chip initialization is taken care of in SystemInit() called
       * from the startup code. SystemInit() and chip settings are defined
       * in the CMSIS system_<part family>.c file.
       */

  /* NVIC is installed inside UARTInit file. */
  UARTInit(115200);

  while (1)
  {                /* Loop forever */

    if ( UARTCount != 0 )
    {
      LPC_UART->IER = IER_THRE | IER_RLS;            /* Disable RBR */
      UARTSend( (uint8_t *)UARTBuffer, UARTCount );
      UARTCount = 0;
      LPC_UART->IER = IER_THRE | IER_RLS | IER_RBR;    /* Re-enable RBR */
    }
  }
}

------------------------------------------------------------------------------------
0 Kudos
Reply
3 Replies

2,018 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Sat Apr 30 21:52:54 MST 2011
In the UARTInit routine of the uart.c file find the following lines:

  /* Enable the UART Interrupt */
  NVIC_EnableIRQ(UART_IRQn);

Hover the mouse over NVIC_EnableIRQ and then press F3.  It will open the file where this happens.  It is part of CMSIS.
0 Kudos
Reply

2,018 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tungsys on Sat Apr 30 20:09:02 MST 2011
Hi Larryvc

Thanks for your guide. But just wonder where is it in the code, the UART_IRQHandler is bind to the UART interrupt vector ?
0 Kudos
Reply

2,018 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Sat Apr 30 12:46:29 MST 2011
Hi tungsys,

Look at the UART_IRQhandler in the file uart.c in the same project.

UARTCount is being reset to 0 in the while(1) loop.  It is not being initialized there.

Larry
0 Kudos
Reply