Programming for Microchip Microcontrollers using the HiTech PICC Compiler

I would like to help program the robot, where do I begin?

The programming phase is over (the competition has ended) but if you'd like to know how to get started on your own robot project this is probably a great place to start. I've updated the PCB file to something much smaller, email if you are interested in something more modern!

First, order the Microchip PIC16F877 from, or request free samples from

Either prepare a breadboard for testing your code on a real PIC, or download this following postscript file, and look at this picture of the top or this one, and this one of the bottom, to create a solid development board, compatible with the bootloader, available at (notice the extra 'c'). To create the board from the positive file, I suggest printing on a transparency and using pre-sensitized boards to develop the circuit; the method is available on the internet. Check your board against the original postscript for shorts - I made the traces a little close. A list of required parts can be viewed here.

Here's what building the board will look like. It's easy!

Download MPLAB IDE from, I suggest MPLAB version 6.12. From the same website, download the acrobat datasheets for the midrange PIC series, as well as for the PIC16F877. This is super important, as any question I get that is answered in the datasheet (please look there first) will be answered with a page number. If you have a problem with the datasheet then please ask.

Download the free C compiler from; you are interested in the PICC Lite, which compiles for, among other PICs, the PICF877A. Download their user manual. Read this file on how to set up the compiler to work with MPLAB, and to start a project. The setup file is for their PICC demo and MPLAB version 5.70.40, you are using the PICC Lite and MPLAB version 6.12, so make the necessary changes.

Download this zip file containing example projects. You will need to create your own projects, depending on which version of MPLAB you want to use, but you can just copy over the source files, or look at them where they are as examples. The robot code has been started in the "robot6" project. For multiple source projects like the robot6 project you need to add the project directory to the include directory in project options.

I don't have a programmer, or my programmer doesn't support this chip, can I still help?

Of course! That's the purpose of this development board - the chip can program itself with a bootloader. To program your chip, you will need a finished board, as well as a PIC16F877 programmed with the bootloader. I can add the bootloader to any chip you provide, or you can download the file ( and program it yourself if you have access to a programmer (there's several in the micros lab). The bootloader is a one time install, and from then on you use the PC application to program your board. In fact, the resourceful engineering student will can produce this development board for about $10. Mine was $18, because I used a fancy ZIF socket and couldn't find a free sample oscillator. Note: I am having trouble with my serial routines and the PIC16F877A chip, so I recommend you use the PIC16F877 (sans 'A') unless you'll be helping me correct the problem. Also, this board may be used with the 18 series and any other 40 pin PIC which has write access to it's program memory (PIC16F874, PIC18F452, etc).

I would like to use another microcontroller, why must I program for the PIC?

The PIC is inexpensive enough for anyone interested in working with us to have their own development board. We have already begun coding for the PIC using HiTech's free compiler. You can program it in C, which everyone knows how to do. It offers access to interrupts. And has enough pins for the I/O we plan to do, plus hardware UART.

I'm trying to print a string with an escape sequence, and the compiler is crashing on me. Why?

Since we'll be needing to send byte data out the UART, you will undoubted like to be able to mix specific bytes in your strings. I found a bug in the compiler that causes it to crash when it encounters a character excape sequence that is followed by regular characters, such as "\xFFHello World". "Hello World\xFF" compiles fine, however. To get around this, separate your strings after your escape characters, so that regular characters don't follow in the same string.

I'm stuck, help!

Don't panic, just email me!