[lpc1343] uarttest example not working

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

[lpc1343] uarttest example not working

1,011件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Joram on Mon May 31 07:38:56 MST 2010
I'm trying to get the uarttest example working but the characters i'm receiving with hyperterminal or a visual studio application do not match. Most of the time i receive a ?.

What i've done is cut a rs232 cable in half and made a header to the rx,tx and signal ground. Connected those to the lpc1343 board(the one you can break apart) and ajusted the example so it send automaticly some text every second or so:

if (send_i > 200000)
{
UARTBuffer[0] = 'a';
UARTBuffer[1] = 'b';
UARTBuffer[2] = 'a';
UARTBuffer[3] = 'b';
UARTBuffer[4] = '/0';
UARTSend( (uint8_t *)UARTBuffer, 5 );
send_i = 0;
}
send_i++;


what i receive is: O???O???O???O???O???O???O???O???O

do i have to connect more from the rs232 cable or change some settings in the application?
0 件の賞賛
17 返答(返信)

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by boltnut on Mon Aug 25 08:46:51 MST 2014
According to UM10375 page 203 algorithm, UART_PCLK=12MHz, BR=115200,
the suggested UART setup would be: DLM, DLL=4, DIVADDVAL=5, and MULVAL=8.
But NXP  LPC13xx_SampleSoftware v107 demo code used DIVADDVAL=0, and MULVAL=1
as default values. Why ?
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Thu Jun 03 07:18:59 MST 2010
Hi All,
Indeed a RS-232 driver is required between the PC and the LPCXpresso.
You could use a USB to UART cable instead.

Kind regards,
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by raimond on Tue Jun 01 10:10:47 MST 2010

Quote: Joram
but the difference is the problem?



It's not quite the 3.3V or 5V value as it is the inverting problem. The RS232 inverts the signal. So a "1" at the logic level (your micro) should be sended as (at least) 0V and a "0" should be sended as 3.3V or 5V or so.

The RS232 standard is" +3..+12V for "0" and -3..-12V for "1". This "one" can be aproximately as 0V, it works with newer PCs and laptops.

So, you NEED to invert the signals.
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Joram on Tue Jun 01 09:12:15 MST 2010
but the difference is the problem?
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by domen on Tue Jun 01 09:00:16 MST 2010
rs232 is not even 5V
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by renan on Tue Jun 01 08:52:53 MST 2010
Did you do your board or is it an LPCXpresso?

Renan
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Joram on Tue Jun 01 05:34:15 MST 2010
why, because my computer rs232 is 5v and the lpc1343 is 3v?
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by domen on Tue Jun 01 04:56:01 MST 2010

Quote: Joram
yes i did directly connected it, it was a rs232 extension cable



You should put something like max3232 level shifter in between.
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Joram on Mon May 31 23:54:57 MST 2010
yes i did directly connected it, it was a rs232 extension cable
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Europe on Mon May 31 23:32:16 MST 2010
Hi Joram,
The code you send seems to be from the example bundle so that should work fine.
I do have one question though, did you connect the LPC1343 directly to you PCs com-port using the cutted RS232 cable?


Quote: Joram

What i've done is cut a rs232 cable in half and made a header to the rx,tx and signal ground. Connected those to the lpc1343 board(the one you can break apart) and ajusted the example so it send automaticly some text every second or so:



Thanks,
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Joram on Mon May 31 11:54:05 MST 2010
i've connected the other pins but no result.

Here is my code:
/*****************************************************************************
 *   uart.c:  UART API file for NXP LPC13xx Family Microprocessors
 *
 *   Copyright(C) 2008, NXP Semiconductor
 *   All rights reserved.
 *
 *   History
 *   2008.08.21  ver 1.00    Preliminary version, first Release
 *
******************************************************************************/
#include "LPC13xx.h"
#include "uart.h"

volatile uint32_t UARTStatus;
volatile uint8_t  UARTTxEmpty = 1;
volatile uint8_t  UARTBuffer[BUFSIZE];
volatile uint32_t UARTCount = 0;

/*****************************************************************************
** Function name:UART_IRQHandler
**
** Descriptions:UART interrupt handler
**
** parameters:None
** Returned value:None
** 
*****************************************************************************/
void UART_IRQHandler(void)
{
  uint8_t IIRValue, LSRValue;
  uint8_t Dummy = Dummy;

  IIRValue = LPC_UART->IIR;
    
  IIRValue >>= 1;/* skip pending bit in IIR */
  IIRValue &= 0x07;/* check bit 1~3, interrupt identification */
  if (IIRValue == IIR_RLS)/* Receive Line Status */
  {
    LSRValue = LPC_UART->LSR;
    /* Receive Line Status */
    if (LSRValue & (LSR_OE | LSR_PE | LSR_FE | LSR_RXFE | LSR_BI))
    {
      /* There are errors or break interrupt */
      /* Read LSR will clear the interrupt */
      UARTStatus = LSRValue;
      Dummy = LPC_UART->RBR;/* Dummy read on RX to clear 
interrupt, then bail out */
      return;
    }
    if (LSRValue & LSR_RDR)/* Receive Data Ready */
    {
      /* If no error on RLS, normal ready, save into the data buffer. */
      /* Note: read RBR will clear the interrupt */
      UARTBuffer[UARTCount++] = LPC_UART->RBR;
      if (UARTCount == BUFSIZE)
      {
        UARTCount = 0;/* buffer overflow */
      }
    }
  }
  else if (IIRValue == IIR_RDA)/* Receive Data Available */
  {
    /* Receive Data Available */
    UARTBuffer[UARTCount++] = LPC_UART->RBR;
    if (UARTCount == BUFSIZE)
    {
      UARTCount = 0;/* buffer overflow */
    }
  }
  else if (IIRValue == IIR_CTI)/* Character timeout indicator */
  {
    /* Character Time-out indicator */
    UARTStatus |= 0x100;/* Bit 9 as the CTI error */
  }
  else if (IIRValue == IIR_THRE)/* THRE, transmit holding register empty */
  {
    /* THRE interrupt */
    LSRValue = LPC_UART->LSR;/* Check status in the LSR to see if
valid data in U0THR or not */
    if (LSRValue & LSR_THRE)
    {
      UARTTxEmpty = 1;
    }
    else
    {
      UARTTxEmpty = 0;
    }
  }
  return;
}

/*****************************************************************************
** Function name:UARTInit
**
** Descriptions:Initialize UART0 port, setup pin select,
**clock, parity, stop bits, FIFO, etc.
**
** parameters:UART baudrate
** Returned value:None
** 
*****************************************************************************/
void UARTInit(uint32_t baudrate)
{
  uint32_t Fdiv;
  uint32_t regVal;

  UARTTxEmpty = 1;
  UARTCount = 0;
  
  NVIC_DisableIRQ(UART_IRQn);

  LPC_IOCON->PIO1_6 &= ~0x07;    //  UART I/O config
  LPC_IOCON->PIO1_6 |= 0x01;     // UART RXD
  LPC_IOCON->PIO1_7 &= ~0x07;
  LPC_IOCON->PIO1_7 |= 0x01;     // UART TXD
  // Enable UART clock
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12);
  LPC_SYSCON->UARTCLKDIV = 0x1;     // divided by 1

  LPC_UART->LCR = 0x83;             // 8 bits, no Parity, 1 Stop bit
  regVal = LPC_SYSCON->UARTCLKDIV;
  Fdiv = (((SystemCoreClock*LPC_SYSCON->SYSAHBCLKDIV)/regVal)/16)/baudrate ;//baud rate

  LPC_UART->DLM = Fdiv / 256;
  LPC_UART->DLL = Fdiv % 256;
  LPC_UART->LCR = 0x03;// DLAB = 0
  LPC_UART->FCR = 0x07;// Enable and reset TX and RX FIFO.

  // Read to clear the line status.
  regVal = LPC_UART->LSR;

  // Ensure a clean start, no data in either TX or RX FIFO.
// CodeRed - added parentheses around comparison in operand of &
  while (( LPC_UART->LSR & (LSR_THRE|LSR_TEMT)) != (LSR_THRE|LSR_TEMT) );
  while ( LPC_UART->LSR & LSR_RDR )
  {
regVal = LPC_UART->RBR;// Dump data from RX FIFO
  }
 
  // Enable the UART Interrupt
  NVIC_EnableIRQ(UART_IRQn);

#if TX_INTERRUPT
  LPC_UART->IER = IER_RBR | IER_THRE | IER_RLS;// Enable UART interrupt
#else
  LPC_UART->IER = IER_RBR | IER_RLS;// Enable UART interrupt
#endif
  return;
}

/*****************************************************************************
** Function name:UARTSend
**
** Descriptions:Send a block of data to the UART 0 port based
**on the data length
**
** parameters:buffer pointer, and data length
** Returned value:None
** 
*****************************************************************************/
void UARTSend(uint32_t *BufferPtr, uint32_t Length)
{
  
  while ( Length != 0 )
  {
  /* THRE status, contain valid data */
#if !TX_INTERRUPT
  while ( !(LPC_UART->LSR & LSR_THRE) );
  LPC_UART->THR = *BufferPtr;
#else
  /* Below flag is set inside the interrupt handler when THRE occurs. */
      while ( !(UARTTxEmpty & 0x01) );
  LPC_UART->THR = *BufferPtr;
      UARTTxEmpty = 0;/* not empty in the THR until it shifts out */
#endif
      BufferPtr++;
      Length--;
  }
  return;
}

/******************************************************************************
**                            End Of File
******************************************************************************/
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by renan on Mon May 31 09:36:37 MST 2010
Try connecting CTS and RTS. I have a RDB1768 from Code Red, and my cable has 5 pins connected:
CTS, RTS, TX, RX  and GND

I'm using their example and everything works perfectly here. I haven't read the example to see if they are needed, but this is how I'm using.

Renan
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by renan on Mon May 31 09:24:55 MST 2010
So, your application and/or hyperterminal Com port do have the same configuration as the example?

Could you post the code for the example also?

Renan
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Joram on Mon May 31 08:45:09 MST 2010
my visual studio application which listens to the serial port, the application is good cause it worked with my atmega32 and other things
but also hyperterminal gives bad output
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by renan on Mon May 31 08:41:38 MST 2010
Where do you receive this?

Quote:

O???O???O???O???O???O???O???O???O



Renan
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Joram on Mon May 31 08:10:33 MST 2010
i haven't changed anything, what i can see in the code is:
8 bits, no Parity, 1 Stop bit
port 0
i've tried 9600 and 115200 baudrate
0 件の賞賛

966件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by renan on Mon May 31 07:52:02 MST 2010
What's your port configuration in your PC and in your board?
Baud rate, port, data bits, stop bits, parity...


Renan
0 件の賞賛