UART 1 issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UART 1 issue

577 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hetech on Sun Oct 12 22:22:32 MST 2014
I have some small code I wrote that uses USART 0 via IRQs.
It works fine with USART 0 or USART 2 (with minor changes), but if I try UART1, I cannot receive or send anything.
Of course I am changing the SCU pin assignments to suit the relevant UART for each test

Even without IRQs, Trying to send a byte via UART1 does nothing (I have checked the pin with a CRO).
UART1 is using PIN 63 / 65

// UART1 (USART_PCLK = 12MHz)
LPC_SCU->SFSP5_6 = 4|(1<<6);// P5.6 GPIO2[15] UART1 TxD
LPC_SCU->SFSP5_7 = 4|(1<<6);// P5.7 GPIO2[7] UART1 RxD

LPC_CGU->BASE_UART1_CLK = (6<<24);// Set to XTAL (12MHz)

LPC_UART1->LCR= 3|(1<<7);// Line control
LPC_UART1->FDR= 5 | (8<<4);// Baud Divider*8/5
//LPC_UART1->DLL= 4;// Baud Diviser LSB 115,200
LPC_UART1->DLL= 8;// Baud Diviser LSB 57,600
LPC_UART1->DLM= 0x00000000;// Baud Diviser MSB
LPC_UART1->FCR= 0x00000007;// FIFO control
LPC_UART1->TER= 0x00000001;// TX EN
LPC_UART1->LCR= 3;// Line control
LPC_UART1->THR= 0x41;// TX 'A'
//LPC_UART1->IER= 2;// TX IRQ enabled
Labels (1)
0 Kudos
7 Replies

520 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hetech on Sun Jan 04 15:07:01 MST 2015
Interesting, I will try that, but like I said, the exact same code works on all the other USARTs.
I should be back on that project next week..

0 Kudos

520 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by agemoz on Sat Jan 03 14:33:42 MST 2015
Did you get this resolved?  I wondered why the TXD pin has the input buffer enabled, I would think you would not want that set--ie:

LPC_SCU->SFSP5_6 = 4             // P5.6 TxD
0 Kudos

520 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hetech on Sun Nov 02 16:42:56 MST 2014
I am using Pin 63 as TxD1 and Pin 65 as RxD1 (LPC4337JBD144)
Thats P5_6 as function 4
P5_7 as function 4

LPC_SCU->SFSP5_6 = 4 | (1<<6);// P5.6  TxD
LPC_SCU->SFSP5_7 = 4 | (1<<6);// P5.7 RxD
0 Kudos

520 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hetech on Sun Nov 02 16:20:55 MST 2014
The pin tables are a nightmare, My guess is that NXP had trouble routing the silicon.

I created an excel spread sheet to help match GPIO names to Pin names.  Also one of the ports has GPIO not as function 0 :)

I am not sure if UART1 is receiving, but I know it is not transmitting.  The pin is always high, but then again by default the IC has input with internal pullup, so it would appear the same if the UART pins were not setup.
I will check the pins again.

-Sam
0 Kudos

520 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hangdog on Sun Nov 02 15:40:11 MST 2014
Wow, I fully missed that the other day, sorry. I've got nothing else, I don't think.

UART1 looks the same as USART0, but with the addition of flow control and the loss of synchronous mode. So long as MCR isn't messed with, I'd guess that flow control won't interfere. Your code seems to match mine, and in any case you say it works for USART0, so that's that I guess.

You 100% sure on your pinning? Those tables mess me up from time to time. Otherwise, the code I've got does things in a slightly different order, though I shouldn't think that's the problem. It goes:

SCU
CLK
FCR
LCR |= DLAB
DLM
DLL
LCR &= ~DLAB
FDR
LCR = whatever
TER = TXEN

Cheers
0 Kudos

520 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hetech on Sun Nov 02 14:41:03 MST 2014
LPC_UART1->LCR = 3|(1<<7); // Line control
^^ Raises DLAB as DLAB is bit 7 (1<<7)

LPC_UART1->LCR = 3; // Line control
^^ DLAB is now set low as all bits but 3 are now 0

The code does work for USART 0 and USART2
Is there something different with UART1 that I need to do? (As its not a USART)

0 Kudos

520 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hangdog on Fri Oct 31 07:28:52 MST 2014
You're not raising DLAB when you set in DLL, DMM. I'm not sure what the defaults are, but I'm guessing they're unsuitable.

Try:
LCR |= DLAB;
DLL = ...
DLM = ...
LCR &= ~DLAB;

Not an expert, but this jumps out at me, cheers.
0 Kudos