UART TXD

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

UART TXD

877 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lba0129 on Fri Mar 13 05:15:23 MST 2015
Hi I have copy some code from the net, and then rearrange it to my project.
I would like to have a TX debug pin. And I set up the uart and sends the data to the uart. But nothing happens on PIO_04, any ideas ?

Here is my code.
void uart0Init(uint32_t baudRate)
{
  uint32_t clk;
  const uint32_t UARTCLKDIV=1;
  GPIOSetPortBitDir(PORT0, TXD_PIN, SET_AS_OUTPUT);
  LPC_SWM->PINENABLE0 |= (1<<0);  //Disable ACIMP

  LPC_SWM->PINASSIGN0 = (0xffffff00 + TXD_PIN);
  /* Setup the clock and reset UART0 */
  LPC_SYSCON->UARTCLKDIV = UARTCLKDIV;
//  ctl_mask_isr(UART0_IRQn);//NVIC_DisableIRQ(UART0_IRQn);
  LPC_SYSCON->SYSAHBCLKCTRL |=  (1 << 14);
  LPC_SYSCON->PRESETCTRL    &= ~(1 << 3);
  LPC_SYSCON->PRESETCTRL    |=  (1 << 3);

  /* Configure UART0 */
  clk = SystemCoreClock/UARTCLKDIV;
  LPC_USART0->CFG = UART_DATA_LENGTH_8 | UART_PARITY_NONE | UART_STOP_BIT_1;
  LPC_USART0->BRG = clk / 16 / baudRate - 1;
  LPC_SYSCON->UARTFRGDIV = 0xFF;
  LPC_SYSCON->UARTFRGMULT = (((clk / 16) * (LPC_SYSCON->UARTFRGDIV + 1)) /
    (baudRate * (LPC_USART0->BRG + 1))) - (LPC_SYSCON->UARTFRGDIV + 1);

  /* Clear the status bits */
  LPC_USART0->STAT = UART_STATUS_CTSDEL | UART_STATUS_RXBRKDEL;

  /* enable rx interrupts (http://jaromir.xf.cz/phone/phone1.html) */
// LPC_USART0->INTENSET = (1 << 0);
   
  /* Enable UART0 interrupt */
//  ctl_unmask_isr(UART0_IRQn);//NVIC_EnableIRQ(UART0_IRQn);

  /* Enable UART0 */
  LPC_USART0->CFG |= UART_ENABLE;  
}

void uart0SendChar(char buffer)
{
  /* Wait until we're ready to send */
  while (!(LPC_USART0->STAT & UART_STATUS_TXRDY));
  LPC_USART0->TXDATA = buffer;
}

void uart0SendByte(uint8_t buffer)
{
    /* Wait until we're ready to send */
    while (!(LPC_USART0->STAT & UART_STATUS_TXRDY));
    LPC_USART0->TXDATA = buffer;
}

void uart0Send(char *buffer, uint32_t length)
{
  while (length != 0)
  {
    uart0SendChar(*buffer);
    buffer++;
    length--;
  }
}

Best regadrs
Lars
Labels (1)
0 Kudos
Reply
4 Replies

785 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lba0129 on Mon Mar 30 06:44:54 MST 2015
This is okay by me, I made it around to use the ROM Api. and then i figure out that I had move it to the wrong pin, so simpel can it be  0:)

Lars
0 Kudos
Reply

785 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xianghuiwang on Sat Mar 28 09:55:53 MST 2015
I would recommand using Tx ( Rx) as gpio to test out your hardware. Or at least probe it out for continuity.
Once the hardware is confirmed, bring up a functioning LPCOpen project. Debug into your project and the LPCOpen project to compare your system, uart clock initialization related register setting as well as status register setting/reading to see if something is not set up properly.
Just reading a big portion of untested code can take some time.
Regards!
0 Kudos
Reply

785 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lba0129 on Thu Mar 26 14:16:28 MST 2015
Hi Sorry has been around I use Rowley so non of them.

I have looks at the one for LPC expresso but think they are twinkled together with a lot of common files.

So I haven't found the solution yet.
0 Kudos
Reply

785 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nerd herd on Mon Mar 16 07:40:00 MST 2015
Hi Lba0129,

What MCU and board is in your possession? Also, NXP has an LPCOpen software platform which is essentially a bunch of sample projects (including UART) that we support in three IDEs: Keil uVision, IAR EWARM, and our free Eclipse based LPCXpresso. I'd rather trust our code rather than someone else's floating around the internet ;)

Here's a link to the download page for the LPC800 series:

http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc8xx-packages
0 Kudos
Reply