![]() |
ME Labs, Inc. 719-520-5323 |
![]() |
![]() |
![]() |
PICBASIC™ Compiler How do I decide between the PICBASIC™ Compiler and the PICBASIC PRO™ Compiler?The main benefits of PICBASIC PRO over the PICBASIC Compiler are access to more RAM, programs longer than 2K, arrays, direct access to any I/O pin and register without using PEEK and POKE, BS2 library commands, built-in LCD support, improved I2C implementation to talk to more devices than serial EEPROMS and real IF..THEN..ELSE. There is also a way to tell Pro what clock oscillator you want to operate at instead of the 4Mhz PBC expects. Pro can be used with MPASM for better ICE and simulator compatibility. The standard PICBASIC Compiler is still quite capable. If you need maximum BS1 compatibility, or you are using only the smaller PICmicros, the PICBASIC Compiler could make a lot of sense. It is, of course, also less expensive than Pro. more information Does the PICBASIC Compiler or the PICBASIC PRO Compiler work with the PIC16C5x (505, 52, 54, 55, 56, 57, 58) parts? The standard PICBASIC Compiler does not support these parts. Their 12-bit core only has a 2-level stack and the compiler requires the 8-level stack of the mid-range 14-bit core PICmicros. There are suitable pin-compatible replacements for the 54, 56 and 58. The PIC16C554, 558, 620, 621 and 622 are an updated version of those 16C5x parts and are available in about the same price range. They have expanded features and work well with either the PICBASIC Compiler or the PICBASIC PRO Compiler. PICBASIC PRO Compiler has limited support for the 16C5x series PICmicros. What about the PIC12C508, 509, 12CE518 and 519? The standard PICBASIC Compiler does not support these parts. These 8-pin PICmicros also have the 12-bit core and thus only a 2-level stack. The 8-pin PIC12C671, 672, 12CE673 and 674 have the 14-bit core and work with either compiler. PICBASIC PRO Compiler has limited support for the 12C5xx series PICmicros. I want to run a serial port at a baud rate other than 300, 1200, 2400 or 9600. Can either compiler do this? There are several ways to run at baud rates other than those listed. PICBASIC PRO's DEBUG, DEBUGIN, HSERIN, HSEROUT, SERIN2 and SEROUT2 instructions allow the setting of any baud rate. The simplest way in the standard compiler is to change the clock oscillator to something other than 4MHz. If you run the PICmicro® at 8MHz and tell it to use 9600 baud, for example, the actual bit rate will be 19,200 baud. Another method is to alter the baud rate table in the compiler library file. This is an ASCII text file that can be changed with any text editor (a backup should be made first). You can also use a PICmicro with a hardware serial port and set the baud rate to just about anything. The hardware USART on the PIC16C63, 65(AB), 73(ABC) or 74(ABC) may easily be accessed by simply PEEKing and POKEing it with the PICBASIC Compiler. See the PICBASIC USART sample program for an example. Or it can be set directly with the PICBASIC PRO Compiler. How do I use the A/D converter on a PIC16C7xx device? The A/D converter on the PIC16C7xx series parts may be accessed using either the PICBASIC PEEK and POKE instructions or by using the in-line assembler feature. See the PICBASIC ADC71 sample program for an example. These registers can be read and written directly using the PICBASIC PRO Compiler. See the PICBASIC PRO ADC7x sample program for an example. Can I use PortA (C, D, E) with the PICBASIC Compiler? As with the A/D converter above, PortA (and other ports on PICmicros with more pins) may be accessed using either the PICBASIC PEEK and POKE instructions or by using the in-line assembler feature. See the PORTA sample program for an example. How do I use an LCD with PICBASIC Compiler? Of course, an LCD serial backpack from Scott Edwards Electronics may be used in conjunction with the SEROUT instruction, just as with a BASIC Stamp. Or an LCD module may be connected directly to 6 or 7 PICmicro I/O pins. See the PICBASIC LCD sample program for an example. Do the PICBASIC and PICBASIC PRO Compilers work with the Microchip programmer? The PICBASIC and PICBASIC PRO Compilers generate standard .HEX files that can be used with most PICmicro programmers including Microchip's PICStart Plus and Parallax's PICmicro programmers. Why do I get errors when I try to use PICBASIC Compiler with Microchip's MPLAB? See the MPLAB installation page. PICBASIC PRO Compiler 1. What's different between the PICBASIC PRO Compiler and the BASIC Stamp II?The main differences between Pro and the BS2, other than Pro programs are faster and can be longer, are some additional instructions and some changes in the way some of the instructions work. There is no nibble data type in Pro. Since Pro can access more RAM, it is usually not a problem to make these byte type variables. The MAX and MIN operators have been altered to work in a more standard manner. Also, since expression operators have precedence, the ordering of math instructions or the addition of parenthesis to specify the order of execution should be examined. SLEEP is uncalibrated. IF..THEN..ELSE..ENDIF provides more than a simple conditional GOTO. Any program code can occur within the structure. And, of course, there are the new LCDOUT and I2C instructions, assembler capability, interrupts and access to more I/O pins. 2. Does the PICBASIC Compiler or the PICBASIC PRO Compiler work with the PIC16C5x (505, 52, 54, 55, 56, 57, 58) parts? PICBASIC PRO Compiler has limited support for the 16C5x series PICmicros. The standard PICBASIC Compiler does not support these parts. There are suitable pin-compatible replacements for the 54, 56 and 58. The PIC16C554, 558, 620, 621 and 622 are an updated version of those 16C5x parts and are available in about the same price range. They have expanded features and work well with either the PICBASIC Compiler or the PICBASIC PRO Compiler. 3. What about the PIC12C508, 509, 12CE518 and 519? PICBASIC PRO Compiler has limited support for the 12C5xx series PICmicros. The standard PICBASIC Compiler does not support these parts. The 8-pin PIC12C671, 672, 12CE673 and 674 have the 14-bit core and work with either compiler. 4. Does the PICBASIC Compiler or the PICBASIC PRO Compiler work with the PIC18Cxxx and 18Fxxx parts? PICBASIC PRO Compiler is compatible with the 18C and 18F series parts, but you will need to download and install the Microchip Assembler, MPASMWIN. For your convenience, we have provided a page with the download and instructions. 5. How do I use the HSerin and HSerout commands at 9600 baud with a 4MHz clock frequency? The compiler calculates the value for the SPBRG register based on the HSER_BAUD define statement, and it assumes that the BRGH bit in the TXSTA register is low. For many of the PICmicro MCU devices, baud rates greater than 2400 with a 4MHz clock result in a low SPBRG value which, in turn, causes a high baud rate error. To correct this, you should set SPBRG and the BRGH bit (TXSTA.4) explicitly with defines. The following defines will allow you to use 9600 baud with a 4MHz clock at less than 0.5% error. DEFINE HSER_SPBRG 25 Consult the PICmicro MCU datasheet for further explanation of the hardware-serial registers. 6. Why do I get an "out of memory" error when I try to compile? Compiling large PICBASIC PRO source code files can tax the memory of the PC running the compiler. If an Out of Memory error is issued, an alternate version of PBP can be used. PBPW.EXE has been compiled to make use of all of the memory available to Windows 95, 98, NT and 2000. You must, of course, be running in a DOS shell from one of those Windows environments or within Microchip's MPLAB. To execute the Windows version from the DOS command line, simply substitute PBPW for PBP. PBPW options filename 7. My program ran fine on the orignal PIC, but it behaves erratically or doesn't run when I put it on a different PIC. When you move to a device with A to D converters or analog comparators, you should disable the analog channels in order to use them as normal I/O. The necessary register setting varies with the PIC, so look in the datasheet for the analog comparators and converters. The registers will be described in detail. Some examples for different PICs. ADCON1 = 7 ' disable A/D converters on most
PICs 7. Do the PICBASIC and PICBASIC PRO Compilers work with the Microchip programmers? The PICBASIC and PICBASIC PRO Compilers generate standard .HEX files that can be used with most PICmicro programmers including Microchip's PICStart Plus and Parallax's PICmicro programmers. 8. Why do I get errors when I try to use PICBASIC PRO Compiler with Microchip's MPLAB? See the MPLAB installation page. 9. Why do I get assembly errors when I use MPASM, but PM works fine? MPASM defaults to case-sensitive operation. Normally this will have no noticeable effect on programs, unless in-line assembly code is used. PBP DEFINEs like OSC and the LCD definitions must be in all upper-case as shown in the examples in the manual. 10. How do I run PBPW from a shortcut and make the screen stick around so I can read it? Put in something like: C:\Command.com /c C:\pbp\pbpw.exe (+ parameters) in cmd line field in the "Program" dialog tab and un-check "Close on exit." 11. Why won't my program write to code space on a 16F87x using the WriteCode command? ReadCode works fine. You must set a configuration bit that enables the write operation. If you are using the EPIC programmer, check the configuration option: Flash Program Write Enable 12. Why do I get the error "Found label after column 1. (clrw)" when compiling for an 18 series PIC? In MPASMWIN 3.60, Microchip moved some of the command redefinitions that PBP depended on. The problem has been fixed in the latest version of PBP. If you are getting the error with an earlier version of PBP, you can add the following at the beginning of your program: @ include "migrate.inc" EPIC™ Programmer For help with troubleshooting, see the EPIC Troubleshooting Page. Does the EPIC Programmer work with the PIC16C5x (52, 54, 55, 56, 57, 58) parts? The EPIC Programmer does not support the base-line 16C5x series PICmicro MCUs. It works with serial-programmed PICmicro MCUs (the majority of PICmicro MCUs). There are suitable pin-compatible replacements for the 54, 56 and 58. The PIC16C554, 558, 620, 621 and 622 are an updated version of those 16C5x parts and are available in about the same price range. They have expanded features and work well with the EPIC Programmer. It does work with the 14-pin PIC16C505. How about using the EPIC Programmer or PICBASIC Compiler with PIC17Cxxx parts? Starting with version 2.2, the EPIC Programmer and special PLCC adapters are available to allow it to work with PIC17C7xx microcontrollers. It will still not work with the PIC17C4x microcontrollers. Starting with version 2.2, the PICBASIC PRO Compiler now supports 17Cxxx parts. How do I do in-circuit programming with my EPIC Programmer? Click Help in your EPIC for Windows software. You will find a section on in-circuit programming that shows how to connect the EPIC to your circuit using the 10-pin connector on the EPIC. We have also made this section of the help file available online. Why does EPIC reset my configuration settings every time I program? If you have selected the "Reread File Before Programming" and "Update Configuration" options, EPIC will update the configuration from the HEX file automatically before programming. To make your configuration changes stick, either save the HEX file with the new configuration, or uncheck one of the options above. Why do I get programming errors? See the EPIC Troubleshooting Guide. Why do I receive the error "Unable to load driver PICLPTNT.SYS" when I try to start my EPIC software? Usually, running the EPIC Windows programming software will automatically load the Windows NT/2000 driver. In some cases and with some permissions, the driver may not be properly loaded under NT/2000. A program, NTINST, is included to install or remove the EPIC Windows NT/2000 driver. To clean up a bad install, remove the driver, then reinstall it. You should be logged on as an administrator. To remove the NT/2000 driver: ntinst /remove See the EPIC Troubleshooting Guide. Why do I get an error when I try to run EPIC in Windows, but the DOS version works fine? Usually this is caused by another Windows driver that is occupying the printer port. Hewlett Packard printer drivers commonly cause this. Other devices with a parallel connection like scanners or ZIP drives may also. You should uninstall the drivers for these devices until you find what is conflicting. For printers, try replacing the manufacturers driver with the native Windows driver. See the EPIC Troubleshooting Guide. How can I use a Visual BASIC shell command to launch EPICC and check the return code to know if it programmed successfully? CodeDesigner LiteHow do I launch my EPIC programmer from CodeDesigner Lite with parameters that will automatically open the file and set the target device? Click Programmer >> Programmer Options. Add the following in the Command Line Options box: -dPIC{DeviceName} "{HexFileWinPath}" |
Copyright 2022 ME Labs, Inc. PO Box 8250 Asheville NC 28814 (719) 520-5323 (719) 520-1867 fax email: support@melabs.com |
|