Author Topic: How to use the UART to get data and send data!  (Read 89673 times)

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: How to use the UART to get data and send data!
« Reply #30 on: August 19, 2010, 10:55:53 AM »
Email me if you have any questions, I use serial ports quite a bit (Mostly with the uTasker Modbus module, which is VERY good).

Good luck Martin

Offline Kevin

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: How to use the UART to get data and send data!
« Reply #31 on: September 03, 2010, 02:11:21 AM »
Where are the port assignments for the UART TXD and RXD?  I found CTS and RTS in app_hw_lpc23xx.h.

I want to add two additional uarts one for a radio link and another for irda.
« Last Edit: September 03, 2010, 02:35:21 AM by Kevin »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: How to use the UART to get data and send data!
« Reply #32 on: September 03, 2010, 11:16:47 AM »
Hi Kevin

Depending on the LPC that you are using you will have a number of UARTs. These are numbered 0, 1, 2 etc. for UART0, UART1, UART2 etc.
When the interface is initialised the UART used is defined by tInterfaceParameters.Channel (= 0,1, 2 etc.).

Some of the UARTs themselves have fixed locations (for example on the LPC23XX an LPC24XX UART0 Tx is always on P0.2 and UART0 Rx is always on P0.3).

Other UARTs may have multiple locations (for example on the LPC23XX and LPC24XX UART1 Tx can be on P0.15 or P2.0 and Rx can be on P0.16 or P2.1).

In the case of multiple ports you can configure the project to use certain ones.
In app_hw_lpc23xx.h you will find these defines:

      //#define UART1_PORT2                                      // set for alternative pin uses - TXD1 and RXD1 on P2.0 and P2.1 rather than TXD1 on P0.15 and RXD1 on P0.16
      //#define UART2_PORT2                                      // TXD2 and RXD2 on P2.8 and P2.9 rather than TXD2 and RXD2 on P0.10 and P0.11
      //#define UART3_PORT0_HIGH                                 // TXD3 and RXD3 on P0.25 and P0.26 rather than TXD3 and RXD3 on P0.0 and P0.1
      //#define UART3_PORT4                                      // [only LPC24XX] TXD3 and RXD3 on P4.28 and P4.29 rather than TXD3 and RXD3 on P0.0 and P0.1


They are off, meaning that the standard (default) pins are used. When set, they effectively map the pin use to alternative pin sets.

Note that the RTS and CTS defines are special since not all UARTs have RTS/CTS lines. In this case, so that all UARTs can always be controlled with RTS/CTS irrespective of whether the chip has dedicated lines for this, there is a set of defines used to map GPIOs to RTS/CTS use. The CTS lines need to be on ports with interrupt capability (specifically ports 0 and 2 on the LPC) but otherwise are flexible as to where they actually are.

Regards

Mark

Offline Kevin

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: How to use the UART to get data and send data!
« Reply #33 on: September 04, 2010, 03:05:51 AM »
Thanks.  I initially read the defin as LPC21xxx, but its for not LCP21xx.  Thanks!

-Kevin

Offline internship2

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: How to use the UART to get data and send data!
« Reply #34 on: February 27, 2013, 11:16:43 AM »
Hi i am trying to get some messege out on the Terminal in CodeWarrior. I am trying to use
fnDebugMsg("Hallo world!");
I have
#define DEMO_UART and #define SERIAL_INTERFACE
i am using the right com port
it is becource its not possible to geth out in terminal or Tera Term

I am sitting with a K60F120M tower

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Re: How to use the UART to get data and send data!
« Reply #35 on: February 27, 2013, 02:43:30 PM »
Hi

For the K60F120 board you need

#define DEMO_UART    5


since the serial board is connected to its UART5.

Check also the jumper settings on the serial extension board to be sure that the RS232 lines are connected.

Regards

Mark