<<Previous |
2. Getting Started
2.1. Software Installation
The PICBASIC PRO™ files are compressed into a self-extracting file on the diskette. They must be uncompressed to your hard drive before use. This can be done for DOS or Windows. To uncompress the files from
DOS, create a subdirectory on your hard drive called PBP or another name of your choosing by typing:md PBP
at the DOS prompt. Change to the directory:
cd PBP
Assuming the distribution diskette is in drive a:, uncompress the files into the PBP subdirectory:
a:\pbpxxx -d
where
xxx is the version number of the compiler on the disk. Don=t forget the -d option on the end of the command. This ensures that the proper subdirectories within PBP are created.Alternatively, INSTALL.BAT can be run to perform similar steps. If the PBP directory already exists, you will get an error message and the installation will continue.
Make sure that FILES and BUFFERS are set to at least 50 in your
CONFIG.SYS file. Depending on how many FILES and BUFFERS are already in use by your system, allocating an even larger number may be necessary.To install PICBASIC PRO™ from Windows, run A:\INSTALL.BAT from the Run box in the Windows Start menu.
See the README.TXT file on the diskette for more information on uncompressing the files. Also read the READ.ME file that is uncompressed to the PBP subdirectory on your hard drive for the latest PICBASIC PRO™ Compiler information.
2.2. Your First Program
For operation of the PICBASIC PRO™ Compiler you
=ll need a text editor or word processor for creation of your program source file, some sort of PICmicro programmer such as our EPIC Plus Pocket PICmicro Programmer, and the PICBASIC PRO™ Compiler itself. Of course you also need a PC to run it all on.The sequence of events goes something like this:
First create the BASIC source file for the program using your favorite text editor or word processor. If you don
=t have a favorite, DOS EDIT (included with MS-DOS) or Windows NOTEPAD (included with Windows and Windows95/98) may be substituted. The source file name should (but isn=t required to) end with the extension .BAS.The text file that is created must be pure ASCII text. It must not contain any special codes that might be inserted by word processors for their own purposes. You are usually given the option of saving the file as pure DOS or ASCII text by most word processors.
The following program provides a good first test of a PICmicro in the real world. You may type it in or you can simply copy it from the
SAMPLES subdirectory included with the PICBASIC PRO™ Compiler. The file is named BLINK.BAS. The BASIC source file should be created in or moved to the same directory where the PBP.EXE file is located.' Example program to blink an LED connected to PORTB.0 about once a second loop: High PORTB.0 ' Turn on LED Pause 500 ' Delay for .5 seconds Low PORTB.0 ' Turn off LED Pause 500 ' Delay for .5 seconds Goto loop ' Go back to loop and blink LED forever End
Once you are satisfied that the program you have written will work flawlessly, you can execute the PICBASIC PRO™ Compiler by entering
PBP followed by the name of your text file at a DOS prompt. For example, if the text file you created is named BLINK.BAS, at the DOS command prompt enter:PBP blink
The compiler will display an initialization (copyright) message and process your file. If it likes your file, it will create an assembler source code file (in this case named
BLINK.ASM) and automatically invoke its assembler to complete the task. If all goes well, the final PICmicro code file will be created (in this case, BLINK.HEX). If you have made the compiler unhappy, it will issue a string of errors that will need to be corrected in your BASIC source file before you try compilation again.To help ensure that your original file is flawless, it is best to start by writing and testing a short piece of your program, rather than writing an entire 100,000 line monolith all at once and then trying to debug it from end to end.
If you don
=t tell it otherwise, the PICBASIC PRO™ Compiler defaults to creating code for the PIC16F84. To compile code for PICmicros other than the >F84, simply use the -P command line option described later in the manual to specify a different target processor. For example, if you intend to run the above program, BLINK.BAS, on a PIC16F877, compile it using the command:PBP -p16f877 blink
2.3. Program That PICmicro
There are two steps left - putting your compiled program into the PICmicro microcontroller and testing it.
The PICBASIC PRO™ Compiler generates standard 8-bit Merged Intel HEX (
.HEX) files that may be used with any PICmicro programmer including our EPIC Plus Pocket PICmicro Programmer. PICmicros cannot be programmed with BASIC Stamp programming cables.The following is an example of how a PICmicro might be programmed using our EPIC Programmer with the DOS programming software.
Make sure there are no PICmicros installed in the EPIC Programmer programming socket or any attached adapters.
Hook the EPIC Programmer to the PC parallel printer port using a DB25 male to DB25 female printer extension cable.
Plug the AC adapter into the wall and then into the EPIC Programmer (or attach 2 fresh 9-volt batteries to the programmer and connect the
ABatt ON@ jumper. Using an AC adapter instead of batteries is highly recommended.)The LED on the EPIC Programmer may be on or off at this point. Do not insert a PICmicro into the programming socket when the LED is on or before the programming software has been started.
From Windows, start EPICWin. EPICWin is the 32-bit Windows version of the programming software and should be used with Windows 95, 98, ME, NT or 2000.Enter:
If you only have DOS or Windows 3.1, use the DOS version of EPIC. The EPIC DOS software should be run from a pure DOS session. The EPIC DOS software only supports a limited number of PICmicro MCUs. Use EPICWin for programming the latest PICmicro microcontrollers. See the EPIC readme file for the complete support list.
The EPIC software will take a look around to find where the EPIC Programmer is attached and get it ready to program a PICmicro. If the EPIC Programmer is not found, check all of the above connections and verify that there is not a PICmicro or any adapter connected to the programmer.
Once the programming screen is displayed, use the mouse to click on Open file or press Alt-O on your keyboard. Use the mouse (or keyboard) to select
BLINK.HEX or any other file you would like to program into the PICmicro from the dialog box.The file will load and you should see a list of numbers in the window at the left. This is your program in PICmicro code. At the right of the screen there is a display of the configuration information that will be programmed into the PICmicro. Verify that it is correct before proceeding.
In general, the Oscillator should be set to XT for a 4MHz crystal and the Watchdog Timer should be set to ON for PICBASIC PRO™ programs. Most importantly, Code Protect must be OFF when programming any windowed (JW) PICmicro. You may not be able to erase a windowed PICmicro that has been code protected. You can find more information on these configuration fuses in the Microchip data sheet for the device you are using.
When it all looks marvelous, it is time to insert a PICmicro into the programming socket and click on Program or press Alt-P on the keyboard. The PICmicro will first be checked to make sure it is blank and then your code will be programmed into it. If the PICmicro is not blank and it is a flash device, you can simply choose to program over it without erasing first.
Once the programming is complete and the LED is off, it is time to test your program.
2.4. It
=s AliveThe sample schematic below gives you an idea of the few things that need to be connected to the PICmicro to make it work. Basically all you need is a pull-up resistor on the /MCLR line, a 4MHz crystal with 2 capacitors, and some kind of 5-volt power supply. We have added an LED and resistor to provide the output from the
BLINK program.
Build and double check this simple circuit on a breadboard and plug in the PICmicro you just programmed. Our line of PICProto prototyping boards is perfect for this kind of thing.
Connect a power supply. Your PICmicro should come to life and start blinking the LED about once a second. If it does not blink, check all of the connections and make sure 5 volts is present at the appropriate pins on the PICmicro.
From these simple beginnings, you can create your own world-conquering application.
<<Previous |