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 get any bytes on the pc(sometimes i get lot of garbage bytes i have no idea from where)
    Can both UART 0 and UART1 access data from same memory?
    I mean UART1 will receive data and keep it in UART1 FIFO.But how does UART0 access that FIFO??

    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 get any bytes on the pc(sometimes i get lot of garbage bytes i have no idea from where)
    Can both UART 0 and UART1 access data from same memory?
    I mean UART1 will receive data and keep it in UART1 FIFO.But how does UART0 access that FIFO??

    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
  • Why do you feel that a full duplication of your previous post improve your chances to get an answer?

    Where is the text where you tell us your ideas and what you have tried and if it worked or why it failed?

  • hi,

    i know full duplication will not improve my chance of getting my answer,but if you carefully observe i have added few more sentences to make my question clear.
    i have mentioned the code which i have tried and if i knew the reason why it is not working,i would not have added my post in this forum.Please provide any valuable suggestion if u have
    thanks

  • As you may notice, your code is totally unreadable, since you did not follow the posting instructions. Just above the "message" input box, there is information about how to post source code.

    No, one UART can't access the FIFO of another uart.

    Depending on processor, you will have the following alternatives:
    - activate the DMA to automagically transfer data from one UART receive FIFO to the other UART transmit FIFO.
    - write an interrupt routine that picks up received characters from one FIFO and puts them in the transmit FIFO for the other port (start by putting the characters into the transmit FIFO of the same port to verify that you get a perfect echo function).
    - write polling code that repeatedly checks if there are any characters received on one UART and then copies them to the other UART.

    There are a lot of example code that performs both polled and interrupt-driven communication. Unless the baudrates are extremely high, there shouldn't be any need for the DMA solution.

    If the receive UART has a higher baudrate than the transmit UART, then you must use the handshake signals, XON/XOFF or any other method for implementing flow control.

    So, select a solution. Read the user manual. Look at the examples. Edit the example code until it fits your requirements.

  • Thanks for ur help.i am sorry i didn't post my source code in proper manner.
    I would like to try 2 and 3 option as i am not sure whether mcb2140 supports dma or not.Please can u specify some manual or document or simple examples which help me understand as i have never implemented isr.

  • NXP can supply examples.
    Keil already has supplied examples.
    Have you looked at them?