chipKIT® Development Platform

Inspired by Arduino™

Fubarino mini UART pin issue

Created Tue, 11 Aug 2015 10:19:34 +0000 by GastonLagaffe


GastonLagaffe

Tue, 11 Aug 2015 10:19:34 +0000

Salut,

playing with the Fubarino I have found an issue with the UART1 and UART2: I use the following simple code:

void setup() {

//	mapPps(17,PPS_OUT_U1TX);
//	mapPps(18,PPS_IN_U1RX);
//	mapPps(26,PPS_OUT_U2TX);
//	mapPps(25,PPS_IN_U2RX);
	Serial.begin(9600);
	Serial0.begin(9600);
	Serial1.begin(9600);
}

void loop() {


	Serial.println("Hello World 1");
	Serial0.println("Hello World 2 UART1");
	Serial1.println("Hello World 3 UART2");
	delay(1000);
}

When compiling with UECIDE 0.8.7z36 I have UART1_TX on RA0 (5) and UART2_TX on RC2 (13). Un-commenting the mapPps call does not change anything. Compiling with mpide (2.8.2015) I have UART1_TX on RB4(17) but output is ")aayvé^.&V) ©" at 9600 baud, which is also the bytes I receive when connecting the serial monitor to RA0 or RC1.

When compiling using UECIDE Beta18 I get the same behavior as with MPIDE.

I have no idea what is going wrong here ... The board definition file shows the correct settings to use pins 17/18 and 25/26

Ciao, Mathias


EmbeddedMan

Tue, 11 Aug 2015 14:57:39 +0000

What if you do the PPS mapping AFTER opening the UARTs? I'm trying to remember, and I think we might do PPS mapping (according to what is in the variant file) during the begin() call. So if you do your PPS mapping immediately after the begin(), it should work correctly in every case.

As far as differences between UECIDE and MPIDE versions and such - I would venture to guess that the variant files are slightly different between the different versions, and that's why you're seeing differences. Just a guess.

*Brian


GastonLagaffe

Tue, 11 Aug 2015 15:18:19 +0000

Salut Brian,

I moved the mapPps calls without change:

  • on UECIDE the pins get not reassigned
  • on UECIDE BETA/MPIDE, the pins are already correct.

I still have the effect that the output received from the terminal connected to the UART is garbled. I tried on a different board and the output is ok. The difference is that the other board has a PIC32MX250F128B processor, this problem one has a PIC32MX250F128D processor.

Ciao, Mathias


GastonLagaffe

Wed, 12 Aug 2015 08:13:40 +0000

Salut,

I tried SoftwareSerial with the same result: The pins are assigend correctly but the printed output is garbled, It appears to me like there is a timing issue with the Fubarino definitions.

Ciao, Mathias


GastonLagaffe

Wed, 12 Aug 2015 08:46:00 +0000

Salut,

I was right with my guess that there is something working with the timing. The fubarino was flashed with the UECIDE hex file (found in the fubarino board definition folder). I now flashed the chip with the bootloader Fubarino-Mini_USB_48MHz.hex from UECIDE alpha18 and the serial output is perfectly ok.

In summary for the fubarino: use bootloader and code from UECIDE alpha18 or MPIDE

Ciao, Mathias


majenko

Wed, 12 Aug 2015 10:11:44 +0000

I think the old bootloader code (the original bootloader) was set for 40MHz operation. The newer Minis run at 48MHz, and the bootloader is set accordingly. By putting on an older bootloader you would have been running slower than the core thought you were, and all the baud rate calculations would be incorrect.