This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

make com0 and com1(serial ports)of mcb2140 work simultaneously

Hi,

I have mcb2140 which two serial ports COM1 and COM0.
I want to connect COM1 to my computer and COM0 to other evaluation board PN544.

I want to basically send commands from my computer to arm board through COM1 and then send command to pn544 evaluation board through COM0 and in turn get and pass response from PN544 to computer via arm board.

Please can anyone suggest how sould i do this.

1)Can two serial ports on arm board work simulataneously.

2)Any specific jumper settings required?

3)Can anyone explain me what is
PINSEL0 = 0x00050000;
U1LCR = 0x83;
U1DLL = 97;
U1LCR = 0x03;

how do we define which serial port to use com1 or com0

4)what is U1THR,U1LSR?

cose is as follows:(serial.c)

#include <LPC21xx.H> /* LPC21xx definitions */

#define CR 0x0D

void init_serial (void) { /* Initialize Serial Interface */ PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */ U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLL = 97; /* 9600 Baud Rate @ 15MHz VPB Clock */ U1LCR = 0x03; /* DLAB = 0 */
}

/* implementation of putchar (also used by printf function to output data) */
int sendchar (int ch) { /* Write character to Serial Port */

if (ch == '\n') { while (!(U1LSR & 0x20)); U1THR = CR; /* output CR */ } while (!(U1LSR & 0x20)); return (U1THR = ch);
}

int getkey (void) { /* Read character from Serial Port */

while (!(U1LSR & 0x01));

return (U1RBR);
}

---
Looking for any suggestion.
thanks

Parents
  • thanks a lot for ur reply.The mcb2140 manual is really helpful .It cleared many of my doubts but now i am stucked up with this problem .pl can u suggest what is wrong..
    I have read the mcb2140 manual and set the registers for com0 and com1 at baudrate 115200.
    Arm board com0 is connected to the pc's serial port
    Arm board com1 is connected to another chip PN544 evaluation board.
    Pn544 on reseting sends few bytes which I want to scan or read through com1 and send it to pc through com0 to the pc (basically the arm board acts as an interface between pc and another chip).
    But the problem is I don't exactly the same bytes on PC from Pn544 when it is directly connected without the arm board throuch serial cable.

    I just want am board to act as an interface.Please suggest any ideas possible to make it work

    the code is
    for serialcom0 and com1 settings:

    void init_serial0 (void)
    { PINSEL0 = 0x00000005; U0LCR = 0x83; U0DLL = 8; //115200 Baud Rate @ 15MHz VPB Clock //U0DLL = 97; // 9600 Baud Rate @ 15MHz VPB Clock U0LCR = 0x03;
    }

    void init_serial1 (void)
    { PINSEL0 = 0x00050000; U1LCR = 0x83; U1DLL = 8; U1LCR = 0x03;
    } -------------------
    int main(void)
    { int j; char c; char st[50]; int cmd[4]= 0;

    while(1) { j = 0; init_serial1(); scanf("%d",&j); init_serial0(); sendchar(j); printf("\n"); }
    } --------------
    int sendchar (int ch) {

    if( PINSEL0 == 0x00050000) { if (ch == '\n') { while (!(U1LSR & 0x20)); U1THR =CR; } while (!(U1LSR & 0x20)); return (U1THR = ch); } else if( PINSEL0 == 0x00000005) { if (ch == '\n') { while (!(U0LSR & 0x20)); U0THR = CR; } while (!(U0LSR & 0x20)); return (U0THR = ch); }
    }

    int getkey (void) {

    if( PINSEL0 == 0x00050000) { while (!(U1LSR & 0x01)); return (U1RBR); } else if( PINSEL0 == 0x00000005) { while (!(U0LSR & 0x01)); return (U0RBR); }
    }

Reply
  • thanks a lot for ur reply.The mcb2140 manual is really helpful .It cleared many of my doubts but now i am stucked up with this problem .pl can u suggest what is wrong..
    I have read the mcb2140 manual and set the registers for com0 and com1 at baudrate 115200.
    Arm board com0 is connected to the pc's serial port
    Arm board com1 is connected to another chip PN544 evaluation board.
    Pn544 on reseting sends few bytes which I want to scan or read through com1 and send it to pc through com0 to the pc (basically the arm board acts as an interface between pc and another chip).
    But the problem is I don't exactly the same bytes on PC from Pn544 when it is directly connected without the arm board throuch serial cable.

    I just want am board to act as an interface.Please suggest any ideas possible to make it work

    the code is
    for serialcom0 and com1 settings:

    void init_serial0 (void)
    { PINSEL0 = 0x00000005; U0LCR = 0x83; U0DLL = 8; //115200 Baud Rate @ 15MHz VPB Clock //U0DLL = 97; // 9600 Baud Rate @ 15MHz VPB Clock U0LCR = 0x03;
    }

    void init_serial1 (void)
    { PINSEL0 = 0x00050000; U1LCR = 0x83; U1DLL = 8; U1LCR = 0x03;
    } -------------------
    int main(void)
    { int j; char c; char st[50]; int cmd[4]= 0;

    while(1) { j = 0; init_serial1(); scanf("%d",&j); init_serial0(); sendchar(j); printf("\n"); }
    } --------------
    int sendchar (int ch) {

    if( PINSEL0 == 0x00050000) { if (ch == '\n') { while (!(U1LSR & 0x20)); U1THR =CR; } while (!(U1LSR & 0x20)); return (U1THR = ch); } else if( PINSEL0 == 0x00000005) { if (ch == '\n') { while (!(U0LSR & 0x20)); U0THR = CR; } while (!(U0LSR & 0x20)); return (U0THR = ch); }
    }

    int getkey (void) {

    if( PINSEL0 == 0x00050000) { while (!(U1LSR & 0x01)); return (U1RBR); } else if( PINSEL0 == 0x00000005) { while (!(U0LSR & 0x01)); return (U0RBR); }
    }

Children
No data