Dear all, I am new to LPC2378..Currently i am developing code for sending a character in serial port....Below i mentioned the code what i have written..but this is not working...i am using keil uvision3...Can anybody help me in this code????In my hardware DB 9 connectors rxd and txd are connected together(loopback test)
This is my code...
#include <LPC23xx.H> #include <stdio.h> void delay(int); int main (void) { PCONP |= (1<<3) /* power for uart 0 */ PINSEL0 |= 0x00000050; /* Enable TxD0 *//* Enable RxD0 */ U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U1DLM = 0x00; U1DLL = 0x78; /* 9600 Baud Rate @ 12MHz Clock */ U1FDR = 0xA3; U1LCR = 0x03; /* DLAB = 0 */ U0FCR = 0x81; while(1) { U1THR = 'A'; while (!(U1LSR && 0x40)); }
.
#include <LPC23xx.H> #include <stdio.h> void delay(int); int main (void) { PCONP |= (1<<3) /* power for uart 0 */ PINSEL0 |= 0x00000050; /* Enable TxD0 *//* Enable RxD0 */ U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U0DLM = 0x00; U0DLL = 0x78; /* 9600 Baud Rate @ 12MHz Clock */ U0FDR = 0xA3; U0LCR = 0x03; /* DLAB = 0 */ U0FCR = 0x81; while(1) { U0THR = 'A'; while (!(U0LSR && 0x40)); }
Any reason why you aren't interested in reading any data?
Sorry Ammu I am not working on serial communication.
But Mr.Per Westermark this forum is meant for clearing the doubts. If you have any suggestions kindly respond with a favorable reply... The queries are not posted to your personal account. If you are not interested others can help her. You are not the admin of this forum.
Mr per westermark
I am very new to microprocessor development and am still figuring out the way things work on the LPC2378. i had already gone to the datasheet and written this code.AS it was not working i asked the reason.How you can be so sure that i haven't read anything.
Thanks k.p coder
I didn't notice any access to any receiver buffer register. So I am explicitly wondering why there is no attempt to read any data.
This is a poster with three threads. One asking about RS-485 using a LPC2148, while explicitly telling us about having already done RS-232 programming.
If the OP has already done RS-232 programming with a LPC2148, which is almost identical to the LPC2378 when it comes to serial communication, then the obvious question is why the OP do not make any attempts to read out any data. Moving from LPC2148 to LPC2378 doesn't remove the need for reading out incomming data if the goal is to receive.
Some people thinks "post the code" is the way to help. I think people should take one step back and actually think when they are stuck. The obvious response would be to try to tell me where the OP thinks data is read out - or why the OP thinks data will magically read itself out of the UART. If there is a Transmit Holding Register for outgoing data, then it doesn't take too much own thought to consider the value of the Receiver Buffer Register for incoming data.
Dear per Westermark,
still iam not able to understand.i am very new to microprocessor development and am still figuring out the way things work on the LPC2378 . So up front apologies for "stupid" questions.This is the code what i have written.kindly tell me the changes that i have to made in my program.I need character 'A' to be displayed on serial window0 while debugging
#include <LPC23xx.H> #include <stdio.h> void delay(int); int main (void) { PCONP |= (1<<3) /* power for uart 0 */ PINSEL0 |= 0x00000050; /* Enable TxD0 *//* Enable RxD0 */ U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */ U0DLM = 0x00; U0DLL = 0x78; /* 9600 Baud Rate @ 12MHz Clock */ U0FDR = 0xA3; U0LCR = 0x03; /* DLAB = 0 */ U0FCR = 0x81; while(1) { U0THR = 'A'; while (!(U0LSR & 0x40)); }
Maybe you could tell us what you meant with "i have done rs232 programing." in this thread: http://www.keil.com/forum/62241/
What did you do when you did your RS-232 programming? Did you just send then? No receiving?
I have already told you that you are not reading out any data. Did you, when you looked at that datasheet, looked at the register "Receiver Buffer Register" that I mentioned? What is your view about this register after having read the datasheet text?
Next thing - You are using the Line Status Register. There you found the bit 0x20 which is Transmitter Holding Register Empty (THRE). Didn't you also find Receiver Data Ready (RDR)? Do you think this bit might be usable when wanting to know if there is data available to read?
The program which i have done in rs 232 programing (LPC 2148)is as follows
FOR TRASNMITTING
void main() {; U0DLL=97; PINSELO=0X00000005; U0LCR=0X83; U0DLL=97; U0LCR=0X03; U0THR='A'; while(!(!(UOLSR&0x40)); while(1); }
. when debugging this code,the character 'A'is displayed on serial window iam also aware of U0RBR which is used for receving like
while(!(U0LSR&0X01)); data 3=UORBR;