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
*argh* Mistake :-)
"Now you have two UARTS, with "blocking" TX and Interrupt RX. That means that every incomming char produces an interrupt. You may fill a buffer with the chars. Handling them directly in the ISR is - of course - possible, but not recommended. Write some high level functions for handling the two uarts as you need."
Regards, /th.
What you should do?
Read the user manual for the processor.
Read all the example code that is supplied with the Keil tools and are available (directly or by reference) from the NXP product page.
Now you will now exactly what the different registers are, and what they do. You will now how to initialize serial prots. You will now how to send and receive.
It should be trival to extend that so that data is forwarded between the serial interfaces.
This is a school assignment, and the assignment is not how to perform distributed development - you should not run around requesting others to do all your job. Your assignment is for you to do. Your teacher should have made sure that you have enough knowledge to know how to perform this assignment. And only by doing the assignment (instead of copying other peoples code) will you be able to learn something new.
1) Would you accept a PC that can't use two serial ports at the same time? Do you think the chip vendor would say that the processor has two serial ports if it only has one serial port that is multiplexed?
2) Doesn't the manual for your board explain all strap fields?
3) Didn't you find the explanation of the UART registers in the processor user manual? Didn't that information make it obvious how you access UART0 or UART1?
4) Didn't the processor user manual contain the information about these registers?
thanks for a long suggestion, however it would be good that instead of suggesting what i should do if you could provide some useful links where I could read and make my questions clear. For your information,this is not a school project.I am new to this field of arm processor and would like to gain knowleadge in this area.I am not expecting any code just wanted to make some points clear. Please remember it might be very simple for you but for someone new in this field it might be very difficult and confusing
It seems you really know a lot in this area so please can you answer my questions or provide some useful links which i can read:
3)Following are setting for serial com 1 PINSEL0 = 0x00050000; U1LCR = 0x83; U1DLL = 97; U1LCR = 0x03;
For com0 are the following ok? PINSEL0 = 0x00000005; U0LCR = 0x00000083; U0DLL = 97; U0LCR = 0x00000003;
4)what is U1THR,U1LSR? ( please Define)
Yes, I recommended the individual steps not to be evil but because you need to perform them to get up to speed. Getting yes/no or copy-paste answers here will not help you even a fraction of the way that the correct use of the individual manuals will. There is no substitute for reading. If this was a school assignment, then getting turn-key solutions may have been an alternative to "pass the test", but since this isn't a school work, true knowledge of the target chip is vital. The cost of producing real equipment and later find out that they are broken can be quite high. And the probability of that happening can be quite high if chip manual + data sheet are not read.
Anyway, more specific answers that still requires you to read the user manual for the chip. Note that NXP has many chips, and knowledge about the concepts does not mean that the people who answer happens to have the user manual (and hence the exact pin configuration bits...) for the specific chip model you ask questions about. Also, the one who cares most about your project is (or should be) you, which is a good reason why the manual is important.
Note that PINSEL0 is a bitmap for a number of pins. You can't assign 0x00000005 to it without overwriting any assign you have already done for the other UART.
Either compute a "total" value for PINSEL0 for all pins controlled by this register, or rewrite the code to perform and + or.
PINSEL0 = (PINSEL0 & ~AFFECTED_PINS) | EXPECTED_VALUES;
Or for your UART0 assign
PINSEL0 = (PINSEL0 & ~0xf) | 0x5; // Enable RXD0 and TXD0
How to control which UART to use? That depends on how you are going to send data. If you mean printf() - use the serach function in the upper right of this web page and you will find a number of references how to redirect printf() output to different ports.
Or create your own com0_printf(), com1_printf() etc that performs a sprintf() and then copies the data to the relevant send buffer.
The manual does a good job of defining the Transmit Holding Register and the Line Status Register.
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); } }