chipKIT® Development Platform

Inspired by Arduino™

DP32, PPS and UARTs

Created Sat, 05 Oct 2013 15:21:12 +0000 by ChristopheDupriez


ChristopheDupriez

Sat, 05 Oct 2013 15:21:12 +0000

Hi!

I am experimenting using UARTs and I am very grateful to Chris (carroper) for explaining many issues with PPS and DP32.

I am testing using the minimal program proposed by Chris (9600 bauds instead of 19200 though)

With UART0, I have RX and TX work as expected (but LED1 is lighting).

With UART1 not redirected or redirected as suggested by Chris, RX works (I receive USB data from MPIDE Serial Monitor) but the board freeze if I send just one character to UART1 (I use PUTTY + 3.3V USB-Serial adapter). MPIDE is then freezed up to the moment I reset the board.

The code for UART0 being the same than for UART1 (HardwareSerial in /hardware/pic32/cores/pic32), I do not understand what is happening. And I need to use UART1 also in the near future.

May be Mr.Gene Apperson would have an idea to make UART1 operational?

Thanks a lot for making MicroChip compatible with Arduino software!

Christophe


majenko

Sat, 05 Oct 2013 18:19:06 +0000

Which version of MPIDE are you using? Until recently there was an issue with interrupts when using any UART other than UART0.

Make sure you have the latest version from [url]http://chipkit.s3.amazonaws.com/index.html?sort=lastmod&sortdir=desc[/url]


ChristopheDupriez

Sun, 06 Oct 2013 07:06:48 +0000

I have installed: builds/mpide-0023-windows-20130715.zip The test version would be recommended? Or should I compare HardwareSerial and import new code ?

Thanks for the advice: I will give it a try next Friday!

Christophe


majenko

Sun, 06 Oct 2013 09:19:46 +0000

You need the latest test version for the fix to be present. You could tweak HardwareSerial, but there are other beneficial changes too.


caroper

Sun, 06 Oct 2013 16:05:31 +0000

Hi Chris,

Did you try it with the examples from my blog post? If so it should work as I fully tested all of them. Allso did you notice this paragraph in particular:

"The code is similar to what we have been using so far except for the mapPps() statements and test string. The most important thing to note is that the mapPps() statements come after the Serial1.begin() Statement. This looks counterintuitive and, as such, was the last thing I tried in a long line of experiments, but it works. For some reason, placing them before the Serial1.begin() will remap the the Tx Pin correctly but it continues to receive on RA1. Placing them after correctly remaps both Tx and Rx pins."

here is the direct link just in case:

http://caroper.blogspot.com/2013/07/in-this-post-we-make-start-with.html

I have the DP32 hooked up at the moment, so if you want to post your code I can test it for you to see is both boards have the same problem.

Cheers Chris (The Other One)


ChristopheDupriez

Sun, 06 Oct 2013 21:23:29 +0000

Chris and Majenko, thanks a lot for the advices!

Looking at the most recent HardwareSerial.cpp, it seems that a real bug was corrected (setIntVector(_SER0_VECTOR, isr); changed to setIntVector(vec, isr);) I will test when I can (I need to change my wiring to test). Apart from that, I see very few changes.

Chris, I add the (very simple) source code which works at the end of the message: the ChipKIT is connected to an XBee and the PC also: data is correctly transfered.

By the way, I notice many tests like: #if defined(PIC32MX1XX) || defined(PIC32MX2XX) to check for PPS. As other MCUs have PPS () like the PIC32MX330/350/370/430/450/470 families, some other formulation will be necessary sooner or later. Do you think Board.h could define a symbol like PIC32_PPS for all boards with a PPS MCU ?

Have a nice evening,

Christophe


void setup() { Serial.begin(9600); Serial0.begin(9600);

// mapPps(3, PPS_OUT_U2TX); I tried (with/without) this and other combinations when I had "Serial1" or 2 instead of Serial0. // mapPps(2, PPS_IN_U2RX );

Serial0.print("Hello World!"); }

void loop() { if(Serial.available()) {
Serial0.print((char)Serial.read()); } if(Serial0.available()) {
Serial.println("Another charater just arrived: ["); Serial.print((char)Serial0.read()); Serial.println("]"); } }