chipKIT® Development Platform

Inspired by Arduino™

Fubarino mini 1.5 serial pins

Created Sat, 17 May 2014 17:08:34 +0000 by ziovic


ziovic

Sat, 17 May 2014 17:08:34 +0000

Hello,

I am facing a strange problem with my fubarino mini 1.5 board( puchased at Microchip direct ). The RX pins are located as stated in the manual, at 18 and 25, while TX pins are at 5 and 13. I tried to move them with mapPps() function, but it works only with RX pins, TX remains at the above mentioned place. For example,

mapPps(23,PPS_IN_U2RX); works,

mapPps(26,PPS_OUT_U2TX); does not.

I am using MPIDE 0023 windows 20140315.

Any suggestion?

Thank you,

Vittorio


EmbeddedMan

Mon, 19 May 2014 21:10:53 +0000

Vittorio,

This should work. I will test it as soon as I get home, and let you know what I find.

*Brian


EmbeddedMan

Tue, 20 May 2014 03:51:08 +0000

OK, your problem is that you're using too old of an MPIDE version. I fixed a bug in some of the more recent versions that had to do with the PPS mapping code, and it may be what's preventing your code from working properly.

Try the 20140511-test version here: [url]https://chipkit.s3.amazonaws.com/builds/mpide-0023-windows-20140511-test.zip[/url]

and see if it works for you.

I've included my test sketch below that shows all 3 serial ports (USB and both UARTS) working at the same time. Note that no PPS calls need to be made to use these default pins.

*Brian

// UART test for Fubarin Mini board
// Test out USB Serial and two hardware UARTs
// Use FTDI or other USB to serial cable with PC and
// terminal emulator for the two hardware UARTs

void setup() {

  Serial.begin(9600);     // USB port - baud doesn't matter
  Serial0.begin(115200);  // UART1 - pins 17 (TX) and 18 (RX)
  Serial1.begin(115200);  // UART2 - pins 26 (TX) and 25 (RX)

  // We wait so that human has time to open up serial monitor port in MPIDE
  delay(5000);

  Serial.println("This is USB serial ");
  Serial0.println("This is serial0 ");
  Serial1.println("This is serial1 ");
  pinMode(PIN_LED1, OUTPUT); 
  digitalWrite(PIN_LED1, HIGH);
}

void loop() {
  Serial.println("This is USB serial ");
  Serial0.println("This is serial0 ");
  Serial1.println("This is serial1 ");
  digitalWrite(PIN_LED1, HIGH);
  if (Serial.available())
  {
    // Echo back what got sent + 1
    Serial.println(byte(Serial.read() + 1));
  }
  if (Serial0.available())
  {
    // Echo back what got sent + 2
    Serial0.println(byte(Serial0.read() + 2));
  }
  if (Serial1.available())
  {
    // Echo back what got sent + 3
    Serial1.println(byte(Serial1.read() + 3));
  }
  delay(200);
  digitalWrite(PIN_LED1, LOW);
  delay(200);
}

ziovic

Tue, 20 May 2014 07:33:16 +0000

Brian,

thanks for your answer. I will give it a try tonight.

Vittorio


ziovic

Tue, 20 May 2014 20:48:31 +0000

Hello Brian,

with the suggested MPIDE I got the correct default pins for UART (25,26 and 18,17). If I remap the U2TX pin with mapPps() to, for example, pin 7 ( RB0), now it works, but I have the serial output on both pin 26 (default one) and 7 ( reassigned). I did not test other pins where U2TX can be mapped, but it looks like I have a multiple assign.

Vittorio


EmbeddedMan

Wed, 21 May 2014 04:16:37 +0000

That is the expected behavior. With outputs, you can map as many (of the possible) pins to a single output function, like a UART's TX, at the same time. (up to 8 I think)

If you want to shut off the TX to the 'old' pin and restore it to GPIO, you can just use it with digitalWrite() (which will un-map it) or use mapPps(x, PPS_OUT_GPIO);

*Brian


ziovic

Wed, 21 May 2014 09:18:40 +0000

Thank you, I got the point.

Is the default PPS mapping defined in the Board_Defs.h ? In other words, if I change the pin number in the port declaration of serial or SPI can I avoid to use the mapPps() function in my sketch?

I am now dealing with SPI, since i want to use the SPIFlash library from Henning Karlsen with Fubarino mini. I have already modified ( slightly ) the UTFT library and I am successfully driving a 2,8" TFT in 8 bit mode, and I need space for bitmaps.

First attempt to map SPI2 pins on Fubarino mini using the example provided on Fubarino web site did not work, and I would like to understand how the PPS default mapping is working in MPIDE.

Any hint will be much appreciated...

Vittorio


majenko

Wed, 21 May 2014 12:58:10 +0000

Yes, it is. For the DSPI library it's the entries:

#define _DSPIx_MISO_IN      PPS_IN_SDIy
#define _DSPIx_MISO_PIN     n 
#define _DSPIx_MOSI_OUT     PPS_OUT_SDOy
#define _DSPIx_MOSI_PIN     n

For the SPI library just drop the D prefix. You'll find them there ok, usually towards the end of the file.


EmbeddedMan

Wed, 21 May 2014 15:25:51 +0000

The default mappings for some peripherals are set up in the Board_Defs.h file, that is correct. For example, we have #define _SER0_TX_PIN 17 #define _SER0_TX_PIN 18 which set up the default PPS settings for that peripheral.

However, there don't appear to be the same types of #defines for SPI on the Mini.

Inside SPI.cpp, the initializer function for the SPI object takes pin numbers for MOSI and MISO, and uses those to do PPS mapping. They come from the Board_Defs.h file: #define _SPI_MISO_IN PPS_IN_SDI1 #define _SPI_MISO_PIN MISO #define _SPI_MOSI_OUT PPS_OUT_SDO1 #define _SPI_MOSI_PIN MOSI (where MISO and MOSI are also found in the Board_Defs.h file, near the top: const static uint8_t MOSI = 26; // PIC32 SDO2 const static uint8_t MISO = 25; // PIC32 SDI2 )

However, that block of #defines for the SPI pins doesn't seem to exist for Fubarino Mini. I'm really surprised, since I thought we tested that. I'll have to get it added in for the next MPIDE build.

You can at that block in yourself, however, and then set the pins to whatever you want them to be (within the limits of PPS).

Does that help?

*Brian


ziovic

Thu, 22 May 2014 07:52:17 +0000

@Majenko Thank you

@Brian Very helpful and clear, thank you. I will add the block as suggested and try.

Vittorio


EmbeddedMan

Thu, 22 May 2014 15:19:00 +0000

I just committed a change to the file that includes default mappings for both SPI ports. You can pull it down and try it out if you want: [url]https://github.com/EmbeddedMan/chipKIT32-MAX/blob/master/hardware/pic32/variants/Fubarino_Mini/Board_Defs.h[/url]

I haven't tested this out yet - I just pushed it up so you can try it if you want. I will be testing it tonight.

*Brian


ziovic

Fri, 23 May 2014 08:04:00 +0000

Thanks,

I have been able to talk with the flash using the default settings of SPI2 of the new Board_Defs.h.

I have used

mapPps ( MISO, PPS_IN_SDI2); mapPps ( MOSI, PPS_OUT_SDO2);

But I could not remap MISO pin ( default 27) to pin 0 (RB13) changing it in the Board_Defs.h. I need the first 8 bit of port C to drive the TFT, so I need pin 27 (RC6), and RB13 is the only one left to remap SDI2 with MX250F128.

Since RB13 is also an analog in, should I configure it as digital before remapping?

Vittorio


EmbeddedMan

Fri, 23 May 2014 14:49:28 +0000

It should work- B13 should be able to be used just the same as C6.

Just for kicks, do a pinMode(0, INPUT); to force that pin as a digital input, then try the remapping. See if that helps.

*Brian


ziovic

Fri, 23 May 2014 20:27:15 +0000

Brian,

pin 0 does not cooperate.

I tested all other pins (9, 12, 20 ) and remapping works flawlessy.

A LED blink test on pin 0 works.

I did not find any possible reason in the datasheet, would be nice to understand what is the problem...

Vittorio


gmaselli

Thu, 18 Dec 2014 10:20:46 +0000

I have the same problem with mapping UART1. In details if I call mapPps(10, PPS_OUT_U1TX) nothing is written on the serial port. After investigatiion I have fixed it changing Board_Defs.h at line 241. The original code was uint8_t and modified into uint16_t fixed my problem. extern const uint16_t digital_pin_to_pps_out_PGM[]; This because Board_defs.c declares the array as uint16_t. I am using Microchip XC32 compiler without bootloader, probably this is more critic about these mismathes. Regards Giorgio