The Arduino™ Blink Sketch on chipKIT DP32

Overview:

In this tutorial, the standard “Hello World” program (blinking LED) is used to help familiarize you with the chipKIT DP32 board and how it will interface with  the Multi-Platform Integrated Development Environment (MPIDE) and basic language functions.  

Reference:

During the course of this tutorial, various terms will be referenced including:
  • Sketch
  • Function
  • Variable
  • HIGH and LOW
  • INPUT and OUTPUT
We recommend that you read the following sections on the Arduino™ homepage to get a better understanding of these terms:

Hardware Used:

The hardware used in this tutorial will be the chipKIT DP32 manufactured by Digilent Inc. The reference guide for this board, schematics and other resources are available on the chipKIT DP32 homepage at: http://www.digilentinc.com/Products/Detail.cfm?NavPath=2,892,1174&Prod=CHIPKIT-DP32  

Software Used:

In this tutorial, the chipKIT MPIDE will be used. If you haven’t already, follow the instructions at the links below to download MPIDE for your operating system:

Hardware Setup:

The DP32 can be powered in a number of ways including from the USB connection (J2) or over the screw terminal (J6). The user needs to select which method will be used to power the board by configuring the jumpers immediately next to the screw terminal as shown below:  

 jumper config

   

Procedure:

  1. Open MPIDE, by navigating to the extracted files in the folder you selected when you downloaded the source files. Locate the MPIDE executable (Windows® folder shown): openMPIDEopenMPIDE Double click the executable to open the MPIDE  Hint: At this point it is a good idea to create a shortcut to the mpide.exe and place on your desktop.
  2. The first time you open MPIDE, you will be notified that a “sketchbook folder” will be created. In Windows, this folder will be located in the “My Documents” directory. scketchbookFolder Click OK to continue.
  3. The MPIDE Window should appear. Note the following main areas of the IDE Window.MPIDE Workspace button overview
  4. The chipKIT MPIDE comes with a variety of examples that can be used to help explore some of the various features of both the MPIDE and the chipKIT Platform. To access these examples, select File>Examples.EXAMPLES Note that there are all kinds of examples from lighting an LED on the chipKIT Board to different types of displays.Under File>Examples>Basic, there is an example called Blink. This example blinks an LED on the chipKIT Board ON/OFF in 1 second intervals. This little program is what is known as the “Hello World” program as it is usually the first application new users create who are using a Microcontroller for the first time.This example could easily be opened and run as is. However, in order to highlight some of the features of the MPIDE, this example will be recreated from scratch.
  5. Click on the “New” button to open a new sketch window and then click “Save” button. Name the sketch something meaningful like DP32_Blink.  The default directory will be the mpide folder created when the MPIDE was first started. Note: If you navigate to the mpide folder, there will now be a new folder with the name of the sketch you just saved.
  6. In this part of the tutorial, you will create a simple routine that will blink LED 3 on the DP32.dp32 Add the following code into the MPIDE editor:
    int ledPin = 43;                 // LED connected to digital pin 26
    void setup()
    {
      pinMode(ledPin, OUTPUT);      // sets the digital pin as output
    }
    void loop()
    {
      digitalWrite(ledPin, HIGH);   // sets the LED on
      delay(1000);                  // waits for a second
      digitalWrite(ledPin, LOW);    // sets the LED off
      delay(1000);                  // waits for a second
    }
  7. There are quite a few things going on with this sketch. Under the “References” section at the top of the page, links are provided that will explain much of the content.Next, we will upload our code to the DP32.
  8. Make sure that the chipKIT DP32 is connected via the mini-B connector on the board to an availableUSB port on the computer.
  9. In MPIDE, select Tools>Board>chipKIT>chipKIT DP32 to identify the DP32 Board as a target select boardselectboard

    Next, you will need to place the DP32 into “Programming” or “Bootloader” mode; otherwise, the sketch will not be able to be uploaded to the board. To enter into this mode, hold down the RESET button followed by the PGM button, then release the RESET button first, followed by the PGM button. You will know you’ve done this correctly if LED1 begins to flash repeatedly. dp32_BUTTONS

    When the DP32 is in Bootloader mode, LED1 on the board will begin to flash on/off.

  10. Next, select Tools>Serial Port>COMxx. This will depend on which port was assigned to the chipKIT DP32 Board when first connected.selectserialport
  11. To load your sketch onto the chipKIT DP32 board’s Microcontroller, press the upload button. This will compile your sketch (check for errors) and then send to the Microcontroller.
 

Verifying Operation:

After the sketch is sent to the chipKIT DP32 board’s Microcontroller, LED 3 on the chipKIT DP32 should flash on and off in 1 second intervals.  
VN:F [1.9.22_1171]
Rating: 6.5/10 (6 votes cast)
VN:F [1.9.22_1171]
Rating: -1 (from 1 vote)

Running StickOS BASIC on a chipKIT board

Have you ever wished you could examine and manipulate the pins and peripherals of your MCU *interactively*, while it was live and connected to your embedded circuit, rather than using just “reset and run” debugging? If so, StickOS BASIC may be for you! With StickOS BASIC, you can log in to your MCU using nothing but a terminal emulator, and then take full control of the MCU from a command-line, just as if you had an In-Circuit Emulator. StickOS can run either in “slave” mode, tethered to and controlled by a host computer as a glorified intelligent I/O port, or it can run in “master” mode, programmed in BASIC, interactively debugged, and even configured to autorun its BASIC program autonomously. In StickOS BASIC, it is trivial to examine and manipulate I/O pins. I/O pins can be configured for digital input or output, analog input or output, servo output, or frequency output. Once a pin is configured, it can be bound to a BASIC variable, and from then on, examining or manipulating the pin is as simple as examining or manipulating the bound variable. For example, to configure pin 3 for servo output, bind it to the variable “motor1”, and then set it up for a 1ms (1000us) PWM pulse width is as easy as (interactively, at the command-line, or in a program):
    > dim motor1 as pin 3 for servo output
    > let motor1=1000
    > _
In StickOS BASIC, it is equally trivial to use timers, UARTs, advanced I2C or SPI peripherals, as well as HD44780-compatible LCDs and simple scanned keypads. And most importantly, it can all be done interactively — no more guessing what your MCU is up to! The StickOS debugger supports command-line program interruption, breakpoints, assertions, watchpoints, live variable (and pin) manipulation and examination, execution tracing and single-stepping, sampling profiling, and even edit-and-continue! When you’re ready to move up, you can then port your BASIC program to C using the MPLAB X StickOS Skeleton project, and take advantage of all the same pin/peripheral configuration, flash manipulation, etc., used by StickOS BASIC. A detailed introduction to StickOS on the chipKIT boards is here: http://www.cpustick.com/chipkit.htm An overview of the StickOS BASIC language features is in the Quick Reference guide, here: http://www.cpustick.com/downloads/quickref.v1.82.pdf More information and downloads for the chipKIT boards are available here: http://www.cpustick.com/downloads.htm
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)