UART auto-flow control and doc error

Showing results for 
Search instead for 
Did you mean: 

UART auto-flow control and doc error

NXP Employee
NXP Employee
Content originally posted in LPCWare by micrio on Mon Jan 16 20:35:03 MST 2012
I am trying to get the auto-flow control working with the UART on a LPC1114/301.   I am working with auto-RTS first. 

When I disable flow control the UART works OK with both Tx and Rx.   So that is not a problem.

When I initialize the modem lines with this code;

[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]// Setup handshake lines.[/COLOR][/SIZE][/COLOR][/SIZE]

[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PIO0_7[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] &= ~0x07;    [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* UART I/O [U]config[/U] */[/COLOR][/SIZE][/COLOR][/SIZE]

[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PIO0_7[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= 0x01;     [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* UART CTS */[/COLOR][/SIZE][/COLOR][/SIZE]

[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PIO1_5[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] &= ~0x07;    [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* UART I/O [U]config[/U] */[/COLOR][/SIZE][/COLOR][/SIZE]

[SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]PIO1_5[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] |= 0x01;     [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* UART RTS */[/COLOR][/SIZE][/COLOR][/SIZE]

[SIZE=2][SIZE=2]  LPC_UART->[/SIZE][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]MCR[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = BIT_6;          [/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]/* Set auto RTS active. */[/COLOR][/SIZE][/COLOR][/SIZE][/SIZE]

the RTS line will be active (observed with a scope).   Everything looks good.

Then I run.   I will take a bunch of interrupts with the IIR returning RLS (Receive Line Status).   The LSR register will be 0xF9 indicating framing error.   This will repeat many times until the RTS pin will go low, it was perviously high.   Reseting the FIFO does not prevent this.   There is no data being sent into the Rx input, this is all during initialization.   This seems OK so far?

After the RTS pin goes low, strangely the Rx pin will also go low.   The Rx pin is being driven by the LPC1114 chip not my ASYNC device.   This is very weird because the Rx pin is an input not an output.   I have looked at the UART configuration registers and they look OK.

Why would the Rx line be driven low by the LPC1114?
Has anyone had success with auto-flow control?  

I have not yet tried auto-CTS so I don't know if that works.   The example code provides a modem setup which is what I am using.   I am using the interrupt handler from the example.   The example works OK until you try auto-flow control.   The example includes the modem setup code but does not use it.


There is a bug in LPCXpresso.   The register definition for the MCR register in the UART has a bit defined wrong.   The RTS_Control bit is listed as bit 2 where the manual says it is bit 1.   The manual is correct.

0 Kudos
2 Replies

NXP Employee
NXP Employee
Content originally posted in LPCWare by micrio on Sat Jan 21 07:23:45 MST 2012
I did finally get it to work OK.   One problem I had was a solder short on two pins.   After fixing that and some further fiddling it now works.   I am only using auto-RTS, I am ignoring CTS.

I have tested this with a scope watching the RxD and RTS lines and it works as expected.  

I tried using auto-CTS and it seems to work but I don't have a suitable ASYNC target to test it.   Windows as a target does not give the control that I wanted.   I did not want to use CTS for my application anyway.

Hope this helps,

Here is my entire init routine;

void UARTInit(uint32_t baudrate)
  uint32_t Fdiv;
  uint32_t regVal, RbrVal;


  // Setup the serial data lines.
  LPC_IOCON->PIO1_6 &= ~0x07;    /* UART I/O config */
  LPC_IOCON->PIO1_6 |= 0x01;     /* UART RXD */
  LPC_IOCON->PIO1_7 &= ~0x07;
  LPC_IOCON->PIO1_7 |= 0x01;     /* UART TXD */

  // Setup handshake lines.
  LPC_IOCON->PIO0_7 &= ~0x07;    /* UART I/O config */
  LPC_IOCON->PIO0_7 |= 0x01;     /* UART CTS */
  LPC_IOCON->PIO1_5 &= ~0x07;    /* UART I/O config */
  LPC_IOCON->PIO1_5 |= 0x01;     /* UART RTS */

   * Enable UART clock
   *  From the manual;
   *  Note that for parts LPC111x/101/201/301, the UART pins must be
   *  configured before the UART clock can be enabled. No enabling
   *  sequence requirement exists for parts LPC11Cxx and parts
   *  LPC111x/102/202/302 and LPC11D14.
  LPC_SYSCON->UARTCLKDIV = 0x1;     /* divided by 1 */

  LPC_UART->LCR = 0x83;             /* 8 bits, no Parity, 1 Stop bit */

  // Calculate the BAUD rate.
  Fdiv = (((SystemCoreClock/LPC_SYSCON->SYSAHBCLKDIV)/regVal)/16)/baudrate ;/* baud rate */

  LPC_UART->DLM = Fdiv / 256;
  LPC_UART->DLL = Fdiv % 256;
  LPC_UART->LCR = 0x03;/* DLAB = 0 */
  LPC_UART->FCR = 0x07;/* Enable and reset TX and RX FIFO. */
//  LPC_UART->MCR = 0xC0;         /* Enable Auto RTS and Auto CTS. */
  LPC_UART->MCR = 0x40;         /* Enable Auto RTS. */

   /* Read to clear the line status. */
  regVal = LPC_UART->LSR;

  /* Ensure a clean start, no data in either TX or RX FIFO. */
  while ( ((regVal = LPC_UART->LSR) & (LSR_THRE|LSR_TEMT)) != (LSR_THRE|LSR_TEMT) );
  while ( (regVal = LPC_UART->LSR) & LSR_RDR )
RbrVal = LPC_UART->RBR;/* Dump data from RX FIFO */

  /* Enable the UART Interrupt in the interrupt controller. */

  // Enable the actual interrupts from the UART.
  LPC_UART->IER = IER_RBR | IER_RLS;/* Enable UART interrupt */


0 Kudos

NXP Employee
NXP Employee
Content originally posted in LPCWare by vineetrvce on Fri Jan 20 01:51:17 MST 2012
  Even I am trying so get the handshake working with UART but no luck. I have the same problem as yours under the thread "UART Handshaking with RTS/CTS" in this forum.

Do post if you find a solution.

0 Kudos