Program the Olimex Pinguino Micro with the Arduino IDE 1.6.8

pinguino+arduino

The Olimex Pinguino Micro is a development board powered by a PIC32MX440F256H 32 bit microcontroller, this processor is clocked at 80 MHz and comes with 256KB Flash and 32KB RAM.

This microcontroller is more powerful than the common Atmega328p, one of the drawbacks of this board back in the day was that out of the box it was only possible to be programmed by the Pinguino IDE, this program lack a lot of features, there is no support for the many libraries that are available for the Arduino and it is outdated. Now this board can be programmed in the Arduino IDE thanks to the work of ChipKit.

The first step is to burn the ChipKit bootloader into the Pinguino Micro. You can download it directly from the GitHub repository of ChipKit. To burn the bootloader you will need a PIC programmer, for this tutorial the PICKit3 programmer was used, here you can see the pin-out.

PICkit3_MCU_Programmer_debuger_pinout

The Pinguino Micro is a very small board and for programming the new bootloader you have to use the six pin In-Circuit Serial Programming (ICSP) connector, this connector however has a very small pitch between pins and you need a matting adapter in order to connect the PICKit 3 to it.

icsp1

To make a ICSP connector you need the MOLEX  51021-0600 or the AMPHENOL FCI  10114826-00006LF, they are just the connectors, you also will need the crimp pins for them AMPHENOL FCI  10114827-001LF and some 32 AWG wires.

molex
Once you have the ICSP connector you will need to solder it to standard 2.54mm pins in order to be connected to the PICKit3. A good idea is to mark the pin one of the connector to connect it correctly to the pin one of the PICkit programmer (the one marked with▼).

connector1

For programming the bootloader you will need to use the MPLAB® Integrated Programming Environment (IPE). You can download it here, For this guide the 3.26 version for Linux 64-Bit was used.

Now that you have all the necessary hardware and software, connect the PICKit3 programmer to the USB port of your PC and open the MPLAB IPE.

pinguino+pickit

On the window look for the Family tab and select 32-bit-MCUs(PIC32), in device select PIC32MX440F256H and in tool you should see the PICKit3.

ipe1

Connect the cable to the Pinguino Micro and click on the “Connect” button on the MPLAB IPE. The IPE may attempt to update the device programmer’s firmware and bootloader, and/or the firmware for the type of device selected. This may take a minute or two, with progress reported in the Output window.

ipe2

If you see the following message “Target device was not found (could not detect target voltage VDD). You must connect to a target device to use PICkit 3.” it is ok, we need to power the board from the programmer. To do so, go to Settings>Advanced Mode, write the default password on the pop up window. Click on the power button on the ICSP section mark the option “Power Target Circuit from Tool” and click the “Operate Button” click disconnect and then connect again. You should see the message Target device PIC32MX440F256H found.

 

ipe3

Now we load the boot-loader into the window, click on the button “Browse” and look for the .HEX file that you download from GitHub, use the file named Olimex_PIC32_Pinguino.hex and click the program button. If you see the message Programming complete the bootloader was loaded on the chip. To be sure you can click on verify to make sure the boot-loader was correctly programmed.

ipe4

ipe5

Unplug the PICKit3 from the PC and the ICSP cable from the Pinguino Micro and connect it to your PC using the USB port of the board.

Open the Arduino IDE, make sure you have the version 1.6.7+. within the Arduino IDE, go to File>Preferences dialog box. Look for the field “Additional Boards Manager URLs:” and add the following URL:

https://github.com/chipKIT32/chipKIT-core/raw/master/package_chipkit_index.json

then click OK . Afterwards select the Tools>Board>Board Manager menu from the Arduino IDE, and it will open up the Boards Manager window. From there, scroll down until you see the chipKIT board. Click once on any of the text in the chipKIT section, and you will see a button appear that says “Install” click on it and wait for some time to download all of the chipKIT components and install them, but when it’s done, you can click the Close button to close the Board Manager window.

Select the PIC32 Pinguino  from the boards list, paste the following code and upload it to the board


/*
    PIC32-PINGUINO
    Blinks both LEDs (Green and Yellow)
   
    If you have any questions, email
    support@olimex.com
    
    OLIMEX, JULY 2012
    http://www.olimex.com
*/



  //Definitions for 
  // -- PIC32-PINGUINO
  // -- PIC32-PINGUINO-OTG
  // -- PIC32-PINGUINO-MICRO
    
  #define BUTTON1INIT TRISDbits.TRISD0 = 1
  
  //YELLOW LED is D1
  #define YLEDINIT   TRISDCLR = 0x02;
  #define YLED1      PORTDSET = 0x02;
  #define YLED0      PORTDCLR = 0x02;
  #define YLEDSWITCH PORTD   ^= 0x02;
  
  //GREEN LED is G6
  #define GLEDINIT     TRISGCLR = 0x40;
  #define GLED1         PORTGSET = 0x40;
  #define GLED0         PORTGCLR = 0x40;
  #define GLEDSWITCH   PORTG   ^= 0x40;
  
  #define YELLOW 0
  #define GREEN  1
  #define BOTH   2


//Blinks an LED five times - mode is YELLOW, GREEN or BOTH
void blinkled(unsigned char mode);
  


void setup() {
    // put your setup code here, to run once:
    YLEDINIT;
    GLEDINIT;
    }

void loop() {
    // put your main code here, to run repeatedly:
    blinkled(GREEN);
    blinkled(YELLOW);
    blinkled(BOTH);
    
    
}

void blinkled(unsigned char mode)
{   
  //Turn off all LEDs
  YLED0;
  GLED0;
  
  char i;
  
  // Blink
  switch(mode)
  {
    case YELLOW:
      for(i=0; i<10;i++)
      {
        YLEDSWITCH;
        delay(100);
      }
      break;
    
    case GREEN:
      for(i=0; i<10;i++)
      {
        GLEDSWITCH;
        delay(100);
      }
      break;
    
    case BOTH:
      for(i=0; i<10;i++)
      {
        YLEDSWITCH;
        GLEDSWITCH;
        delay(100);
      }
      break;
  }       
}

ard-pic32-ide

After this if you see the two leds blinking on the pinguino board, you are done!

led-blink

Now you can program this board with the Arduino IDE.

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *