chipKIT® Development Platform

Inspired by Arduino™

Using additional 2 UARTs with Max32

Created Tue, 06 Jan 2015 19:03:01 +0000 by Magnum


Magnum

Tue, 06 Jan 2015 19:03:01 +0000

Hello,

I am new to this forum and the Max32. I was palying around with an Arduino Leonardo until I found the Max32. I want to build a project with the Max32 where I need at least 5 serial ports. As the software serial is not that powerful I was wondering if is possible to use another one of the hardware UARTs in the PIC. The two additional UARTs are connected to pins 29/43 and A2/A3. Does someone know how to do this? Many thanks.


majenko

Tue, 06 Jan 2015 22:31:06 +0000

There are extra Serial objects already defined for using those ports.

  • The default object, Serial, talks to the normal USB port and pins 0/1.
  • The object Serial1 is configured to talk to pins 18/19.
  • The object Serial2 is configured to talk to pins 16/17
  • The object Serial3 is configured to talk to pins 14/15.

You use Serial1 - Serial3 in the exact same way as Serial.

The other two serial ports aren't configured as objects. You can define your own objects for them by editing the Board_Defs.h file for the MAX32 to enable the other ports. Either that or you can manually access the UART registers to configure it.

To change the Board_Defs.h file, change the number of serial ports from 4 to 6:

#define NUM_SERIAL_PORTS    6

and add the definitions for them:

#define _SER4_BASE      _UART3_BASE_ADDRESS
#define _SER4_IRQ       _UART3_ERR_IRQ
#define _SER4_VECTOR    _UART_3_VECTOR
#define _SER4_IPL_ISR   _UART3_IPL_ISR
#define _SER4_IPL       _UART3_IPL_IPC
#define _SER4_SPL       _UART3_SPL_IPC

#define _SER5_BASE      _UART6_BASE_ADDRESS
#define _SER5_IRQ       _UART6_ERR_IRQ
#define _SER5_VECTOR    _UART_6_VECTOR
#define _SER5_IPL_ISR   _UART6_IPL_ISR
#define _SER5_IPL       _UART6_IPL_IPC
#define _SER5_SPL       _UART6_SPL_IPC

(I have just made this change on the UECIDE MAX32 board definition on the Beta environment).


Magnum

Tue, 06 Jan 2015 22:53:08 +0000

Hello Majenko,

many thanks for your help. Meanwhile I found it out by myself, but you were quicker with your reply. BTW: I am using your IDE, really great work!

What is the MAX32 USB_for_Serial board definition for? I tried to get that running first, as Serial0 is usable with it, but pins 0 and 1 seem to be hard wired to USB. So what's the benefit of that board definition?


majenko

Wed, 07 Jan 2015 00:12:41 +0000

That definition is actually obsolete now. It's all bundled into the normal MAX32 definition.

In the normal MAX32 definition you get an Options submenu in the Hardware menu. In there you can enable or disable USB Serial.

The USB in question isn't the FT232 USB->UART bridge, but the internal USB peripheral in the PIC32 chip. It's available on some boards as an actual USB socket on the board, but not on the MAX32. For that you would have to wire a USB cable into the D+ / D- / Vbus etc pins, or use a shield that presents them as a USB port (I think the Ethernet shield might?)

When you turn that option on Serial becomes the new direct USB port (known as a CDC/ACM port) and Serial0 becomes what was Serial (the FT232 USB->UART bridge on pins 0/1).


Magnum

Wed, 07 Jan 2015 19:26:16 +0000

Many thanks for your quick reply!