11. Compiling a program with PICBASIC PRO

The P-Star is compatible with PICBASIC PRO, a BASIC language compiler from microEngineering Labs that runs on Microsoft Windows and targets PIC microcontrollers. This section explains how to compile a program and load it onto the P-Star using MicroCode Studio, the IDE that comes with PICBASIC PRO. PICBASIC PRO is not free, but there is a trial version that you can try for a limited number of days before deciding whether to purchase PICBASIC PRO.

MicroCode Studio with a simple program for the P-Star 25K50 Micro.

  1. Download and install PICBASIC PRO from the PICBASIC PRO Compiler Downloads page.
  2. Find “MicroCode Studio (MCSX)” in your Start Menu and run it.
  3. Locate the “Microcontroller” dropdown in the upper-left corner, and select the microcontroller on your P-Star, which is either “18F25K50” or “18F45K50”.
  4. Copy and paste this code into your program:
    Define RESET_ORG 0x2000
    Define OSC 48
    
    LED_RED VAR PORTC.6
    mainloop:
       Input LED_RED
       Pause 500
       Low LED_RED
       Pause 500
       Goto mainloop
  5. Click the “Compile” button to compile the program. If you have not saved yet, you will be prompted to choose a location to save the program. After the compilation succeeds, you will have a valid HEX file and you could load it onto the P-Star using the Pololu USB Bootloader Utility (p-load) from the command line. However, we recommend following the instructions below which explain how to integrate p-load with MicroCode Studio so you can load your program onto the P-Star without leaving the IDE.
  6. Locate the “Compile Program” toolbar button and open its menu by clicking the triangle to its right. If you see p-load as an option in this list, then you have probably done these steps before and can skip to step 13.
  7. Select “Install New Programmer…”. In the dialog that opens, select “Create a custom programmer entry” and click “Next”.
  8. For the “Display Name”, enter “p-load”. Click “Next”.
  9. For the “Programmer Filename”, enter “p-load.exe”. Click “Next”.
  10. Click the “Find Manually…” button and select the p-load “bin” folder. If you installed p-load in the default location, the bin folder can be found at “C:\Program Files (x86)\Pololu\USB Bootloader Utility\bin”. Click “Next”.
  11. For the “Parameters”, enter the following line:
    -w $hex-filename$ —pause-on-error
  12. Click “Finished” to finish adding the new programmer, and click “OK” to exit the parent dialog box.
  13. Open the menu for the “Compile Program” toolbar button again to make sure that “p-load” is checked.
  14. Make sure that the P-Star is in bootloader mode as described in Section 5.2. The yellow LED should be on and the green LED should be showing a double-blink pattern.
  15. Click the “Compile Program” button. This compiles the program and runs p-load to load it onto the P-Star.

You should briefly see a window that shows the output from p-load. If everything worked, then the P-Star’s red LED should now be blinking with a period of one second.

Related Products

P-Star 45K50 Mini SV
P-Star 25K50 Micro
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors