I understood why PINSEL0 is used for P0_15 & PINSEL1 is used for P0_16 .
I tend to get confused when i see different codes being used for different Application notes.
PINSEL0 |= 0x00050000; // Select UART1 RXD/TXD
How TXD/RXD is being selected through PINSEL0 inspite it is clear that RXD OF Uart1 can be slected only by PINSEL1 ?
#define TX_BUFSIZE 80 static unsigned char txbuf[TX_BUFSIZE]; static unsigned char txptr = 0; static unsigned char typtr = 0; void UART1_Init(void) { // Fpclk = 12.000.000 MHz // DLM,DLH = Fpclk / (19200*16) = 39 = 0x27 <PINSEL0 |= 0x00050000; // Select UART1 RXD/TXD> U1FCR = 7; // Enable and clear FIFO's U1LCR = 0x83; // 8N1, enable Divisor latch bit U1DLL = 0x27; // baud rate fixed to 19200 @ PCLK = 12 Mhz U1DLM = 0; U1LCR = 3; // Disable Divisor latch bit } static void SendString(char *text) { if (txptr == 0) // previous message send ? { typtr = 0; while(*text) { txbuf[txptr++] = *text++; if(txptr >= TX_BUFSIZE) txptr = 0; } } } static void UART1_Tx_Int(void) // Called from the main loop { char i = 16; if (U1LCR && 0x20) // transmit FIFO empty ? { while (i && txptr) { U1THR = txbuf[typtr++]; txptr --; i --; } } } int main (void) { UART1_Init(); while (1) { SendString("Hello magnificent world of the LPC2000\r\n"); UART1_Tx_Int(); } } I got this code from NXP'S site in application technical note section.
As shown here: www.danlhenry.com/.../keil_code.png
1) You still forgot to tell where you found the code. The NXP site doesn't tell much. Normal answer would be a link to the document.
2) Googling for "Hello magnificent world of the LPC2000" makes me find this link: www.nxp.com/.../MACC05007_LPC2000_UART.pdf
The title is LPC2xxx UART transmitter code example.
Do you know how many chips NXP have that matches LPC2xxx? Do you think every single chip have the same pinout?
Guess what - have a look at the datasheets for LPC21xx and see what it says about P0.8 and P0.9 in relation to UART1.
Examples are examples. Not always 100% copy/paste code.
And most probably, you managed to find an example released years before the existence of the LPC2378 chip.
In the end, I can't know if the link I found is the correct one, since you didn't show a link. But the document I found is correct, based on the chips it was written for. And you will have to figure out what parts of that code that is 100% usable, and what part of that code that should only be given you the ideas what you need to think about while adapting it to your specific needs.
3) Programming is all about details. Details to be found in datasheets. Details about whenapplication examples may be relevant. Details about how to post source code on a web forum - didn't you notice the different look of the source code line in my post? Didn't you then start looking for the reason for that difference?
www.addletters.com/.../bart-simpson-generator.php
"3) Programming is all about details."
details are definitely important, to doing anything. and the advice about reading the datasheet is right on.
however, for a large project, my experience has been that structuring out the whole project and defining / documenting individual tasks dynamically is vital to the timely completion of the project. This is particularly true in a corporate environment where you can borrow, or you have to borrow, from existing code written in a similar fashion. actual programming is usually much simpler after that.
once i have the project diced up in a way that it is manageable even for a junior programmers, or have a process where their feedback can be incorporated at a higher level, I can be fairly confident that the project can be done as scheduled.
heavy investment in structuring and defining the project upfront has always paid off for me.