Line 10: Line 10:
  
 
====RBR ( Receiver Buffer Register )====
 
====RBR ( Receiver Buffer Register )====
 +
The Divisor Latch Access Bit (DLAB) in LCR must be zero in order to access this register
 
====THR ( Transmit Holding Register )====
 
====THR ( Transmit Holding Register )====
 +
The Divisor Latch Access Bit (DLAB) in LCR must be zero in order to access this register
 
====DLL ( Divisor Latch LSB register )====
 
====DLL ( Divisor Latch LSB register )====
 +
The Divisor Latch Access Bit (DLAB) in LCR must be onein order to access this register
 
====DLM ( Divisor Latch MSB register )====
 
====DLM ( Divisor Latch MSB register )====
 +
The Divisor Latch Access Bit (DLAB) in LCR must be one in order to access this register
 
====FCR ( FIFO Control Register )====
 
====FCR ( FIFO Control Register )====
 
====LCR ( Line Control Register )====
 
====LCR ( Line Control Register )====

Revision as of 16:18, 17 March 2015

Amruta (talk) 13:22, 17 March 2015 (IST)


Basics

LPC1768 has 4 UARTS out of which UART0, UART2, UART3 are very similar while UART1 is little bit different from all these.

Registers

Let's have a brief review through some of the important UART registers.

RBR ( Receiver Buffer Register )

The Divisor Latch Access Bit (DLAB) in LCR must be zero in order to access this register

THR ( Transmit Holding Register )

The Divisor Latch Access Bit (DLAB) in LCR must be zero in order to access this register

DLL ( Divisor Latch LSB register )

The Divisor Latch Access Bit (DLAB) in LCR must be onein order to access this register

DLM ( Divisor Latch MSB register )

The Divisor Latch Access Bit (DLAB) in LCR must be one in order to access this register

FCR ( FIFO Control Register )

LCR ( Line Control Register )

LSR ( Line Status Register )

Schematic

Code

Let's make a Decimal Counter with UART .

Initialize the UART0 with 9600 baud-rate.

Display the initial message and go on displaying incremented count taking some pause.

To know more about UART library, check this.

  1. #include "lpc17xx.h" //Device specific header file
  2. #include "uart.h" //Explore Embedded UART library which contains the uart routines
  3. #include "delay.h" //Explore Embedded library containing the delay routines
  4.  
  5. /* start the main program */
  6. int main()
  7. {
  8. uint16_t cnt=0;
  9.  
  10. /* Setup and initialize the microcontroller system */
  11. SystemInit();
  12.  
  13. /* Initialize the UART before Transmitting/Receiving any data */
  14. UART_Init(UART0,9600);
  15.  
  16. UART_Printf("5digit decimal counter: ");
  17.  
  18. /* Transmit the counter till 9999 */
  19. while(cnt < 9999)
  20. {
  21. /* Transmit the 4-digit counter value and go to next line */
  22. UART_Printf("\n\r%4u",cnt);
  23.  
  24. /* Increment the counter value after 1-sec */
  25. DELAY_sec(1);
  26. cnt++;
  27. }
  28. while(1);
  29. }