<<Previous |
2.1. The PICmicros
The PICBASIC™ Compiler produces code that may be programmed into a wide variety of PICmicro microcontrollers having from 8 to 40 or more pins and various on-chip features including A/D converters and hardware timers and serial ports.
There are some PICmicros that will not work with the PICBASIC™ Compiler, notably the PIC16C5x series including the PIC16C54 and PIC16C58. These PICmicros are based on the older 12-bit core rather than the more current 14-bit core. The PICBASIC™ Compiler requires some of the features only available with the 14-bit core, the foremost of which being the 8-level stack.
There are many, many PICmicro MCU, some pin compatible with the '5x series, that may be used with the PICBASIC™ Compiler. Currently, the list includes the PIC12C671, 672, PIC14C000, PIC16C554, 558, 61,
62(AB), 620(A), 621(A), 622(A), 63(A), 64(A), 642, 65(AB), 66, 662, 67, 71, 710, 711, 712, 715, 716, 717, 72(A), 73(AB), 74(AB), 76, 77, 770, 771, 773, 774, 84, 923, 924, PIC16F627, 628, 83, 84(A), 870, 871, 872, 873, 874, 876 and 877. See the READ.ME file for the latest chip support list. For direct replacement of a PIC16C54, 56 or 58, the PIC16C554, 558, 620, 621 and 622 work well with the compiler and are very nearly the same price.*For general purpose PICmicro development using the PICBASIC™ Compiler, the PIC16F84 and PIC16F628 are the current PICmicro
MCUs of choice. These 18-pin microcontrollers uses flash technology to allow rapid erasing and reprogramming to speed program debugging. With the click of the mouse in the programming software, the PICmicro MCU can be instantly erased and then reprogrammed again and again. Other PICmicro MCUs in the 12C67x, 14C000, and 16Cxxx series are either one-time programmable (OTP) or have a quartz window in the top (JW) to allow erasure by exposure to ultraviolet light for several minutes.The PIC16F84 also contains 64 bytes of non-volatile data memory that can be used to store program data and other parameters even when the power is turned off. This data area can be accessed simply by using the PICBASIC™ Compiler's
READ and WRITE commands. (Program code is always permanently stored in the PICmicro's code space whether the power is on or off.)By using the 'F84 for initial program testing, the debugging process may be sped along. Once the main routines of a program are operating satisfactorily, a PICmicro with more capabilities or expanded features of the compiler may be utilized.
While many PICmicro MCU features will be discussed in this manual, for full PICmicro MCU information it is necessary to obtain the appropriate PICmicro MCU Data Sheets or the CD-ROM from Microchip Technology. Refer to Appendix B for contact information.
*Selling price is dictated by Microchip Technology Inc. and its distributors.
2.2. The Pins
Pins used by
PICBASIC™ Compiler commands are numbered 0 - 7 as with the BASIC Stamp I. These pins are mapped onto PICmicro MCU hardware port B such that Pin0 refers to PORTB pin 0 or simply PORTB.0 (or RB0), Pin1 refers to PORTB.1 and so forth up to Pin7 referring PORTB.7. The pin number, 0 - 7, has nothing to do with the physical pin number of a PICmicro. Depending on the particular PICmicro, Pin0 could be physical pin 6, 21 or 33, but in every case it is PORTB.0.PICBASIC™ instructions that reference a pin number such as HIGH or LOW want only the pin number 0 - 7, eg. High 3 (set Pin3 high). If High Pin3 is entered instead, the results are unexpected. Always use only the number or a SYMBOL that equates to a number with pin manipulation instructions.
On the other hand, if the current state of a pin is required, to read a switch for example, the whole pin name would be used, eg. If Pin4 = 0 Then loop. In this case the state of Pin4 (PORTB.4) is read and if it is low (0) the program jumps to the label loop:. If Pin4 is high (1), the program continues with the next instruction after the If..Then.
All of the pins may be set at the same time using the predefined variable Pins. For example, Pins = 255 sets all of the pins high. The variable Dirs is also predefined to allow setting of the pin's directions.
There are only 8 pins, Pin0 - Pin7, defined by the BS1 while a PICmicro may have 13, 22, 33 or more actual I/O pins. Some library routines such as I2COUT make use of some of these additional I/O pins automatically. For access to other I/O pins, the PEEK and POKE instructions were created.
<<Previous |