EmbeddedRelated.com
Forums
Memfault Beyond the Launch

lpc1751 uart

Started by archaiwy July 19, 2010
is there somebody using lpc1751 mcu? I have made uart0/1 work. but the uart2/3 do not. nxp's manual says uart0/2/3 are alike. is it real. why do they not work. Help me to check the initial piece.

void uart_init(void)
{
LPC_PINCON->PINSEL0 &= ~(0xf); // 3
LPC_PINCON->PINSEL0 |= (0xa); // 3
LPC_PINCON->PINSEL1 |= (0xf<<18); // 3
LPC_PINCON->PINSEL9 |= (0xf<<24); // 3

LPC_PINCON->PINSEL0 &= ~(0xf<<4); // 0
LPC_PINCON->PINSEL0 |= (0x5<<4); // 0
LPC_PINCON->PINSEL4 &= ~(0xf<<16); // 2
LPC_PINCON->PINSEL4 |= (0xa<<16);
LPC_PINCON->PINSEL4 &= ~(0xf<<0); // 1
LPC_PINCON->PINSEL4 |= (0xa<<0);
LPC_SC->PCONP |= 0x3000018;
LPC_SC->PCONP |= 0xffffffff;

LPC_PINCON->PINSEL0 &= ~(0xf<<20); // 2
LPC_PINCON->PINSEL0 |= (0x5<<20);

// case 0: //
LPC_UART0->LCR = 0x83; //enable divisor 8bit
LPC_UART0->DLL = 0x81; //lsb
LPC_UART0->DLM = 0x0; //msb
LPC_UART0->FDR = 0xd6; //(1=4/8)
LPC_UART0->LCR = 0x3;
LPC_UART0->IER = 0x1; //enable tx/rx

// case 2: //9600
LPC_UART2->LCR = 0x83;
LPC_UART2->DLL = 0x81;
LPC_UART2->DLM = 0x0;
LPC_UART2->FDR = 0xd6;
LPC_UART2->LCR = 0x3;
LPC_UART2->IER = 0x1;

// case 1: //9600
LPC_UART1->LCR = 0x83;
LPC_UART1->DLL = 0x81;
LPC_UART1->DLM = 0x0;
LPC_UART1->FDR = 0xd6;
LPC_UART1->LCR = 0x3;/
LPC_UART1->IER = 0x1;

// case 3: //9600
LPC_UART3->LCR = 0x83;
LPC_UART3->DLL = 0x81;
LPC_UART3->DLM = 0x0;
LPC_UART3->FDR = 0xd6;
LPC_UART3->LCR = 0x3;
LPC_UART3->IER = 0x1;
}

An Engineer's Guide to the LPC2100 Series

--- In l..., "archaiwy" wrote:
>
> is there somebody using lpc1751 mcu? I have made uart0/1 work. but the uart2/3 do not. nxp's manual says uart0/2/3 are alike. is it real. why do they not work. Help me to check the initial piece.
I don't see the code for PCLKSEL1 to select the clock for the UARTS. Is it in another function?

Richard

Hi:

Looking at you code, it appears that you are connecting UART2 and UART3 to multiples pins. For example,

TXD3 is connected simultaneously to P0.0, P025 and P4.28
RXD3 is connected simultaneously to P0.1, P026 and P4.29.
From the LPC17xx User Manual, Chapter 8, Section 3:

"Multiple connections
Since a particular peripheral function may be allowed on more than one pin, it is in
principle possible to configure more than one pin to perform the same function. If a
peripheral output function is configured to appear on more than one pin, it will in fact be routed to those pins. If a peripheral input function is configured to appear on more than one pin for some reason, the peripheral will receive its input from the lowest port number. For instance, any pin of port 0 will take precedence over any pin of a higher numbered port, and pin 0 of any port will take precedence over a higher numbered pin of the same port."

Without knowing the rest of you hardware connections it is hard to know, but I think this might be the problem: multiple pins connected to the UART, and they are conflicting with each other.

You need to choose only one pair of pins to connect the UART2/3.

Regards,
Alex
--- In l..., "archaiwy" wrote:
>
> is there somebody using lpc1751 mcu? I have made uart0/1 work. but the uart2/3 do not. nxp's manual says uart0/2/3 are alike. is it real. why do they not work. Help me to check the initial piece.
>
> void uart_init(void)
> {
> LPC_PINCON->PINSEL0 &= ~(0xf); // 3
> LPC_PINCON->PINSEL0 |= (0xa); // 3
> LPC_PINCON->PINSEL1 |= (0xf<<18); // 3
> LPC_PINCON->PINSEL9 |= (0xf<<24); // 3
>
> LPC_PINCON->PINSEL0 &= ~(0xf<<4); // 0
> LPC_PINCON->PINSEL0 |= (0x5<<4); // 0
> LPC_PINCON->PINSEL4 &= ~(0xf<<16); // 2
> LPC_PINCON->PINSEL4 |= (0xa<<16);
> LPC_PINCON->PINSEL4 &= ~(0xf<<0); // 1
> LPC_PINCON->PINSEL4 |= (0xa<<0);
> LPC_SC->PCONP |= 0x3000018;
> LPC_SC->PCONP |= 0xffffffff;
>
> LPC_PINCON->PINSEL0 &= ~(0xf<<20); // 2
> LPC_PINCON->PINSEL0 |= (0x5<<20);
>
> // case 0: //
> LPC_UART0->LCR = 0x83; //enable divisor 8bit
> LPC_UART0->DLL = 0x81; //lsb
> LPC_UART0->DLM = 0x0; //msb
> LPC_UART0->FDR = 0xd6; //(1=4/8)
> LPC_UART0->LCR = 0x3;
> LPC_UART0->IER = 0x1; //enable tx/rx
>
> // case 2: //9600
> LPC_UART2->LCR = 0x83;
> LPC_UART2->DLL = 0x81;
> LPC_UART2->DLM = 0x0;
> LPC_UART2->FDR = 0xd6;
> LPC_UART2->LCR = 0x3;
> LPC_UART2->IER = 0x1;
>
> // case 1: //9600
> LPC_UART1->LCR = 0x83;
> LPC_UART1->DLL = 0x81;
> LPC_UART1->DLM = 0x0;
> LPC_UART1->FDR = 0xd6;
> LPC_UART1->LCR = 0x3;/
> LPC_UART1->IER = 0x1;
>
> // case 3: //9600
> LPC_UART3->LCR = 0x83;
> LPC_UART3->DLL = 0x81;
> LPC_UART3->DLM = 0x0;
> LPC_UART3->FDR = 0xd6;
> LPC_UART3->LCR = 0x3;
> LPC_UART3->IER = 0x1;
> }
>


Memfault Beyond the Launch