Code examples

Microstick Plus USB code examples for MPLAB X IDE

The Microchip Libraries for Applications USB software library’s code examples are usable on Microstick Plus USB peripheral panel and the Microstick II development tool together. Before testing the USB software library code examples, some minor changes should be made in the project settings:
  • Change the type of the used microcontroller to:
    • When you are using a PIC24FJ64GB002 open the PIC24FJ64G502_Microstick project configuration scheme and modify the type of microcontroller to PIC24FJ64GB002.
    • When you are using a PIC32MX250F128B open the PIC32_USB_Starter_Kit_II project configuration scheme and modify the type of microcontroller to PIC32MX250F128B.
  • In Hardware Tool list choose the Starter Kits (PKOB) device for debugger and programmer.
  • In case of PIC32MX250F128B microcontroller, delete the PIC32_USB_STARTER_KIT value in the preprocessor macros in xc32-gcc compiler settings.
After changing project settings, copy this two header files to the project folder:
Let the compiler know about new hardware profile file, place these lines at the beginning of general HarwareProfile.h file located in project directory:

// HardwareProfile.h

#ifndef _HARDWARE_PROFILE_H_
#define _HARDWARE_PROFILE_H_

#define DEMO_BOARD MICROSTICK_PLUS_USB
#if DEMO_BOARD==MICROSTICK_PLUS_USB
    #include "HardwareProfile - Microstick Plus USB.h"
#endif

The modified HardwareProfile.h files are available through the links below:
The settings of the configurations bits can be found at the beginning of the main program.
To load the new hardware specified configuration file, include the Configuration Bits – Microstick Plus USB.h header file in conditional compilation mode at the beginning of the Configuration part of the main program.

/** CONFIGURATION **************************************************/
#if defined(MICROSTICK_PLUS_USB)
    #include "Configuration Bits - Microstick Plus USB.h"
#elif defined(...)      // Configuration bits for....

The Device and Host main programs can be downloaded through the links below:
  • Device - HID - Mousemouse.c
  • Host - Mass Storage - Simple Demomain.c
Both main programs contain some technical modifications outside from the previously presented modification, for example switching off the analog mode of the I/O pins.

The mdiified example projects can be downloaded through the link below:
Device - HID - Mouse és Host - Mass Storage - Simple Demo
The modified example programs are based on Microchip USB software library stack version 2.9j. For other examples and the full documentation of USB software library is available on Microchip Libraries for Applications website.