PICBASIC PRO TIPS AND CAUTIONS
1. To get context sensitive help, move the cursor over a PICBASIC command, click to set cursor and press F1.
2. All the programs assume the PIC is running at 4 MHz. To change the default setting (for example, to 20 MHz), simply add DEFINE OSC 20 at the top of your program and set the jumpers on the LAB-X1 accordingly. It is good practice to always specify the oscillator speed in a program. Beginners should start with 4 MHz designs. The LAB-X1 is set up to run at 4 MHz as received from the factory. See the PBP manual for further details of assumptions and conventions used by the software. The defined OSC speed has to match the hardware crystal for the software to work correctly.
3. Before you can use the LCDisplay on the LAB-X1, ADCON1 must be set (to %00000111) and you must pause about 500 ms to allow the LCD to start up before issuing the first command. You may not need a pause, or a shorter pause may be specified if there are a lot of time consuming instructions before the first LCDOUT instruction is executed. (Other values of ADCON1 can also be used depending on how you want the A and E ports configured. See discussion in Chapter 9 on using the LCD.)
4. I have used binary notation (%01010101) throughout the book to set relevant bytes and registers so that you can readily see which bit is being set to what. The compiler
accepts hexadecimal and decimal notation just as willingly. Binary notation does not permit a space after the % sign and all eight bits must be specified.
5. A single quotation mark (‘) when copied from a Word file and pasted into the MicroCode Studio editor will be interpreted as a (`) and will therefore not properly start the comment part of the line. All these have to be changed in the editor after pasting. Pasting from the editor into Word does not exhibit the same effect. If you use a semicolon (;) for the comments, this problem does not occur.
6. All the named registers can be called by name when using the compilers. The register names are the same as those used (defined) by the manufacturer in the data sheets and are the same across the entire family of PIC microcontrollers if they provide the same function. Uppercase or lowercase names can be used. The DEFINEs must be stated in uppercase only and the spellings in the DEFINE lines are not always checked by the compiler! Be very careful when entering DEFINEs into your program.
7. Circuits and segments of circuits are provided throughout this book to show you how to connect up to the hardware when you design your own circuits. If you have access to AutoCAD you can use the diagrams in the files on the support web site to cut and paste into your own designs.
A FREE DEMO BASIC COMPILER
A free version of the PIC Basic Pro compiler by microEngineering Labs can also be downloaded from the microEngineering Labs web site. This is a fully functional com- piler with the limitation that programs are limited to 30 lines of code. This is enough to allow you to test the compiler and any instruction that you might have a special interest in. This version can give you a good idea of the power and ease of use of the language. Try it.