UART – PrintF usage example with UART2

  1. What this example do?
  2. How I must configure my ORbit16™ to work with this example?
  3. Where I can learn more about this?
  4. Download this example!

What this example do?

In the previous example we’ve used PPS with UART1. Now we are going to do the same thing but with UART2 and using the PRINTF function that comes with standard C library <STDIO.H>.

When you press SW2 on ORbit16™, it answers back with a message sent on serial port with the number of times SW2 was pressed. In the meanwhile, L2 will flash indipendently using interrupt on Timer1. Now we’ve a second source of interrupt: the receive interrupt on UART2. When the UART2 receives a byte, it will echoes back on the screen.

PRINTF can works only with ONE UART peripheral, so you must specify the UART with printf must work by setting a variable.

How I must configure my ORbit16™ to work with this example?

For this example you need a serial adapter since the UART on ORbit16™ works at 3.3V. So if you’ve a COM port on you PC, you need an adapter from RS232 to TTL level at 3.3V. If your PC doesn’t have a COM port, you can use an USB/TTL adapter. Please remember your adapter must works with a TTL level of 3.3V.

Using the PPS feature we redirect the UART2 Transmit on port RP14 and UART2 Receive on RP15 (for compactness those ports are identified as P14 and P15 on the ORbit16™). Yes, it is the same configuration of previous example! Don’t forget to connect ground lines together! Here are shown the connections with a 990.004 USB to Serial Micro Converter from Droids.it (click the image for enlarge):

We configure the UART2 peripheral to works at 57600bps, 8 data bits, 1 stop bit, No parity. You can use any terminal software on your pc to see how this demo works:

Where I can learn more about this?

I hope you’ve read the documents adviced in the previous examples, since are the same.

Download this example!

This file is in ZIP format
UART2 - PrintF usage
18.74 kB - Downloaded 35 times