UART1 support for DTR1 in mbed lib?

03 Apr 2010

Is there support for DTR setup in the mbed lib? I took a look and it seems like it does not, if not, is the source around so I can add it? I need flow control and it would be nice to interface to the serial port like all other mbed examples without rewriting it.

03 Apr 2010

Are the UART1 control lines even available?  I can't find them in the MBED drawings.

Anders

05 Apr 2010

DIP 22. DIP 21-26 is UART1

05 Apr 2010

I guess I got confused by seeing TXD1 on both DIP 22 and DIP 13...

05 Apr 2010 . Edited: 05 Apr 2010

For the people who have this question later, here is the answer:

 

I ended up using DTR1 (DIP21) for flow control, the goal was to make a single directional flow controlled UART.

 

#include "mbed.h"              

// look here for LPC regs:
// http://mbed.org/projects/libraries/svn/mbed/trunk/LPC1768/LPC17xx.h

Serial pc(USBTX, USBRX);
Serial uart(p26, p25);

DigitalOut pc_activity(LED1);
DigitalOut uart_activity(LED2);


int main() {

    //
    // Configure uart1 to be placed within the PWD section
    //
    LPC_PINCON->PINSEL4 &= 0x0ffff;
    LPC_PINCON->PINSEL4 |= 0x0AAAA;
    
    LPC_UART1->RS485CTRL = (1<<3)|(1<<4)|(1<<5);
    LPC_UART1->RS485DLY = 128;
   
    while (1) {
        if(pc.readable()) {
            uart.putc(pc.getc());
            pc_activity = !pc_activity;
        }
        if(uart.readable()) {
            pc.putc(uart.getc());
            uart_activity = !uart_activity;
        }
    }
}

11 Nov 2010

what about ctr/rts ??

05 Sep 2011

Hi

RTS is available on the CPU but not connected to the 40 mbed DIP pins.

Btw is the PINSEL4 mask correct if you only need RXD1,TXD1 and DTR1? It seems like it sets all Serial1 pins to Serial Mode where I would only need these 3 pins to drive an RS485 driver.

Wim

05 Sep 2011

Hi,

I also suspect the use of bitwise operations is wrong. In my code i use code like:

    LPC_PINCON->PINSEL1 &= ~(3UL << 14);  /* P0.23, Mbed p15. (AD0) */
    LPC_PINCON->PINSEL1 |=  (1UL << 14);

The first statement resets the affected bits to 0, the second set the wanted pattern. Applied to the code above the lines should read:

    LPC_PINCON->PINSEL4 &= ~(0x0ffff);
    LPC_PINCON->PINSEL4 |=  (0x0AAAA);

Wim