but all execution occurs in hardware in real-time. Pricing: ClearView '5x $499 ClearView 'xx $499 Personality modules $100-$150 Filenames: programmers PEP.EXE (16C5x) PEPX.EXE (16Cxx) PEP17.EXE (17C42) emulator PSIM.EXE All are included with the hardware products, and all are available on the BBS and ftp site. Parallax Inc. fax:(916) 624-8003 3805 Atherton Road, Ste. 102 bbs:(916) 624-7101 Rocklin, CA 95765 USA Help 916-624-8333 .............................. Logical Devices Inc tel:800-331-7766 Programmer ALLPRO 88 tel:305-974-0967 No further information is available at this time Elan Digital Systems Ltd tel:(408) 946-3864 Programmer EF-PER 5000 Series Gang Programmer No further information is available at this time ADVIN Systems Inc tel:408-984-8600 Programmer PILOT U40 No further information is available at this time BP Microsystems tel:800-225-2102 Programmer CP-1128 tel:713-461-4958 No further information is available at this time Data I/O Corp. tel:800-288-4965 Programmer Unisite with Site-48 module No further information is available at this time Stag Microsystems tel:44-707-332-148 Programmer PP39 No further information is available at this time Maple Technology Ltd tel:44-666-825-146 Programmer MQP-200 No further information is available at this time Application Solutions Ltd tel:273-476608 Programmer PIC Programmer No further information is available at this time Citadel Products Ltd. tel:44-819-511-848 Programmer PC-82 No further information is available at this time HI-LO Taiwan ? tel:(02) 7640215 Programmer ALL-03 No further information is available at this time Data I/O Corp. Japan tel:(03) 432- 6991 Programmer Unisite with Site-48 module No further information is available at this time SMS Germany tel:49-7522-4460 Programmer Sprint Expert No further information is available at this time Data I/O Corp. Europe tel:31(0)-6622866 Programmer Unisite with Site-48 module No further information is available at this time Advanced Trans Data ???? tel:(214) 980- 2960 Programmer PGM16 & PGM 16x8 Gang Prog. fax:(214) 980-2937 No further information is available at this time ------------------------------ 3.5) PIC Programming Hardware (D.I.Y.) PIC16C84 Programmer using PC parallel port. Schematic, C and QBasic source available from: Microchip BBS: In 3rd party library as PIC84PGM.ZIP ftp://bode.ee.ualberta.ca /pub/cookbook/comp/ibm/pic84pgm.zip ftp://ftp.luth.se /pub/misc/microchip/16c84/pic84pgm.zip Contact: david.tait@man.ac.uk Author/Designer .............................. A programmer designed by Henk Schaer. Host: faui43.informatik.uni-erlangen.de Location: /mounts/epix/public/pub/Multimedia/VideoCrypt/microcontroller FILE -rw-r--r-- 24693 Apr 7 1994 picprog.zip Complete with software (EXE only). .............................. A design by Mark Cox: Host ftp://baldrick.eia.brad.ac.uk: Location: /pub/blowpic.zip .............................. A design by Russ Reiss appeared in the article "Programming PICs on a Budget" in the June 1994 issue (i.e. #47) of "Circuit Cellar Ink". .............................. PROTO-TYPING BOARDS Proto-typing boards from MicroEngineering Labs. These boards have a large prototyping area, With provisions for a PIC,oscillator circuit, and power supply. For 18-pin PIC16Cxx devices $10 For 18/28-pin PIC16Cxx devices $15 For 40-pin PIC16Cxx devices $17 For 40-pin PIC17C42 $17 Available from Parallax inc. .............................. PIC Experiment Board from Depew Engineering. $199 The Experiment Board supports 18 and 28 pin PICs, includes a solderless breadboard area, clock generation circuit, RS-232 port, I/O port status on LEDs and 7-segment displays, 5-volt power supply, and reset button. The board has support circuitry for 8-pin EEPROMs and BASIC Stamp circuits. Available from Parallax inc. ------------------------------ 4.0) PIC DOCUMENTATION ------------------------------ 4.1) Periodicals that may cover the PIC. The Computer Applications Journal (Circuit Cellar Ink) - programming and construction articles - POB 7694, Riverton, NJ 08077-8784 - FAX: (203)872-2204 - Voice orders: (609) 786-0409 - On-line orders (BBS): (203) 871-1988 - Email orders: ken.davidson@circellar.com - $21.95, $31.95 surface Canada and Mexico, $49.95 air all other countries Computer Design industry announcements and trends One Technology Park Drive, P.O. Box 990, Westford, MA 01886 (508)692-0700 The Computer Journal - programming and construction articles - PO Box 535, Lincoln 96648 Dr. Dobbs Journal - programming articles, concepts and designs - 411 Borel Ave., San Mateo, CA 94402 - (415)358-9500 Electronic Engineering Times - industry announcements and trends - 500-B Bi-County Boulevard, Farmingdale, NY 11735 - (516)293-3000 Electronics Now - construction articles - Box 55115, Boulder, CO 80321-5115 - $19.97 one year Elektor Electronics - programming and construction articles - World Wide Subscription Service Ltd Unit 4, Gibbs Reed Farm, Pashley Road Ticehurst TN5 7HE, England - 27 UK pounds or - Old Colony Sound Lab, - P.O. Box 243, Peterborough, NH 03458 - Tel. (603) 924-6371, 924-6526 - Fax: (603) 924-9467 - $57 USA and Canada per year Embedded Systems Programming - programming and systems design articles - Miller Freeman Publications - 500 Howard St., San Francisco, CA 94105 - (415) 397-1881 Microcomputer Journal (formerly Computer Craft) - programming and constructions articles - 76 N. Broadway, Hicksville, NY 11801 - $18.95 one year, foreign $23.00, foreign air mail $76.00 Midnight Engineering - 1700 Washington Ave., Rocky Road, CO 81067 - (719)254-4553 ------------------------------ 4.2) Books on the PIC A Beginners Guide to the Microchip PIC Nigel Gardner ISBN: 1 899013 00 8 Printed in the UK by Character Press Ltd. Software (on floppy) and hardware guide. Debugging techniques... Available from Polar Electronics in UK 19.95 UK Pounds This is suitably titled as a *beginner's* guide. For those with no previous microcontroller experience. The PIC Source Book: Curious about the inner workings of the BASIC Stamp? Programming the PIC in assembly language? This book/disk combination provides assembly-language source code cloned from more than 30 BASIC Stamp instructions. Shows how to perform serial I/O, read resistance, generate sounds, measure pulses, perform 16-bit math, and more. The package costs $39 S&H. Contact:Scott Edwards Electronics 72037.2612@compuserve.com 964 Cactus Wren Lane Tel: 602-459-4802 Sierra Vista, AZ 85635 Fax: 602-459-0623 CIS: 72037,2612 ------------------------------ 4.3) Miscellaneous documentation on the PIC MicroChip Technology Incorporated - application notes ED Teck. Pubs Fred Eady 407-454-9905 BBS 407-454-3198 Writes articles for popular magazines. Has a PIC programmer kit for $70. BBS available, good source of information, very helpful. Parallax Stamps and programmer, etc. BBS 916-624-7101 Help 916-624-8333 AP Circuits BBS 1-403-291-9342 (Canada) Can download EASYTRAX(V2.06), various utilities, GERBER file proofers, etc. ------------------------------ 5.0) Notes for programmers: All PIC instructions are a single word. The equivalent of the immediateaddress mode of other processors is the literal mode, used by instructionsending in "LW", such as MOVLW, ADDLW, SUBLW, ANDLW, IORLW, XORLW, and RETLW.The byte of data used by these instructions is directly encoded in theinstruction itself. All PIC instructions take a single instruction cycle (four oscillator cycles) to execute, unless a conditional test is TRUE or the program counter is changed as a result of an instruction, in this case the execution takes two instruction cycles. For example: movlw 37 goto next next: movwf porta The goto instruction takes two cycles (1 to get the value of label "next" and 1 to load that value into the program counter) This is useful as a two-cycle NOP, and is often written as "goto .+1" to avoid the need for a label. The W register is equivalent to the accumulator on other processors. Almost all data movement, arithmetic, and logic operations use W. Instructions that operate on W and a register (i.e., instructions ending in "WF", like ADDWF and MOVWF) allow the result to be placed in either W or the register (but not both). This is specified by a ",W" or ",F" after the operand. The default is ",F", which will place the result in the register. This can cause a lot of confusion if you're not careful, so I recommend always specifying the destination explicitly. An example of a confusing instruction: incf foo,w ; w := foo+1 note that foo is unchanged! If you want the result in both W and the register, you can use either: incf foo,w mowwf foo or: incf foo,f movf foo,w The stack is not accessible to the programmer in any way other than the call and return instructions. There is no way to push or pull data, or even to examine the stack pointer. On the 16C5x family the stack has only two levels, so it is frequently necessary to write code in a different style than would be used on a typical processor; you can only call subroutines from your main code, or from a subroutine called from main, but no deeper. If you try to make a 3rd CALL, the 2nd return address is over-written so that the return from the 3rd CALL is OK but the return from the 2nd CALL ends up where the 1st CALL should return to. The 16CXX parts which implement an 8 level stack do so in a circular fashion, so that the 9th CALL over-writes the return address for the 1st CALL. The 16C5x family doesn't have a normal return instruction; instead it has RETLW, which stands for RETurn Literal Word. RETLW loads an eight bit constant into W (just as a MOVLW instruction would), then returns from the subroutine. This can be useful, but is aggravating if you want to return a computed value. On the newer PIC families there is a normal RETURN instruction. With the exception of the 17Cxx family, there is no way for software to read an arbitrary location of program memory. In order to implement lookup tables, it is necessary to combine the use of the ADDWF and RETLW instructions. For example, the following code implements a lookup table of the first four odd prime numbers: primes: addwf pcl retlw 3 retlw 5 retlw 7 retlw 11 To use the table, load the appropriate index (in this case, 0 to 3) into W, and "call primes". The addwf instruction adds the contents of W to the PC, which has already been incremented to point to the "retlw 3". The table will return with the value in W. The total time taken is 6 instruction cycles, or 24 oscillator cycles. Note that while on most processors the use of an out-of-range index will result in the use of incorrect data, but the program execution will continue normally, on the PIC a bad index value will cause the execution of arbitrary instructions! i.e. the computed address must be in the top 1/2 of page. Normally the index would range from 0 to the size of the table minus one, but it is possible to use other ranges by putting the retlw instructions somewhere other than immediately following the "addwf pcl". It is also possible to implement tables using a "subwf pcl", or perhaps other instructions with pcl as the destination. The subtract instructions (SUBWF and SUBLW) work differently than most people expect. SUBWF subtracts W *from* the contents of the register, and SUBLW subtracts W *from* the literal. (SUBLW is not available on the 16C5x family.) If you want to subtract a literal from W, it is easiest to use the ADDLW instruction with the two 's complement of the literal. For example: addlw 0feh ; w := w - 2 Some assemblers allow this to be written as: addlw -2 There is no instruction to take the two 's complement of W (like the NEG instruction on Motorola processors), but because of the way the subtract instructions work you can use: sublw 0 On the 16C5x family, the CALL instruction can only address the first 256 words of a bank of program memory. It is common practice to use "call extenders", which are simply GOTO instructions in the first 256 words with a target in the last 256 words. On the 16C57 and 16C58, if you plan to use indirect addressing (via the FSR and IND registers), it is vitally important that your reset code clear FSR before using any other RAM locations. Otherwise you may start up in an arbitrary bank, and as soon as you change FSR all your carefully set up variables will effectively disappear. Contributed by Eric Smith ------------------------------ 5.1) Useful Code Snippets 5.101) ZERO THE 16C57 RAM 5.102) LONG CALL Macro 5.103) LONG GOTO Macro ------------------------------ 5.101) ZERO THE 16C57 RAM ; The following code was written by Andrew Warren and is ; copyright (C) 1992 by Fast Forward Engineering. Permission ; is hereby granted for any non-commercial use so long as ; this copyright notice is retained. MOVLW PORTA ;PREPARE TO ZERO ALL REGISTERS EXCEPT MOVWF FSR ;THE PROCESSOR STATUS, PC, RTCC, AND FSR ;REGISTERS. CLRRAM MOVLW 00011111B ;ARE WE POINTING AT "USEFSR"? ANDWF FSR,W ; SKPNZ ;IF NOT, SKIP AHEAD. BSF FSR,BIT4 ;OTHERWISE, SKIP OVER THE PROCESSOR ;STATUS, PC, RTCC, FSR, PORTA, PORTB, ;PORTC, AND THE GLOBALLY-ACCESSIBLE FILE ;REGISTERS. CLRF USEFSR ;ZERO THE REGISTER AT WHICH WE'RE ;POINTING. INCFSZ FSR ;HAVE WE DONE THEM ALL? GOTO CLRRAM ;IF NOT, LOOP BACK AND ZERO ANOTHER. ; ALL FILE REGISTERS ARE ZEROED AND WE'RE IN DATA SEGMENT 0. ------------------------------ 5.102) LONG CALL macro ; The following code was written by Andrew Warren and is ; copyright (C) 1992 by Fast Forward Engineering. Permission ; is hereby granted for any non-commercial use so long as ; this copyright notice is retained. ; "Long Call" macro. Invoked by "XCALL any_address". ; Thanks to Chris Dalla for pointing out the need for the "+2" and ; "+1" sums in the last two lines of the macro. XCALL MACRO LABEL DATA 010010100000B+STATUS+256*((LABEL>>9)&00000001B) DATA 010011000000B+STATUS+256*(LABEL>>10) LIST W=1 ;For MPALC/PICALC, make this an "E=2". CALL LABEL LIST W=0 ;For MPALC/PICALC, make this an "E=1". DATA 010010100000B+STATUS+256*((($+2)>>9)&00000001B) DATA 010011000000B+STATUS+256*(($+1)>>10) ENDM ------------------------------ 5.103) LONG GOTO Macro ; The following code was written by Andrew Warren and is ; copyright (C) 1992 by Fast Forward Engineering. Permission ; is hereby granted for any non-commercial use so long as ; this copyright notice is retained. ; "Long Goto" macro. Invoked by "XGOTO any_address". XGOTO MACRO LABEL DATA 010010100000B+STATUS+256*((LABEL>>9)&00000001B) DATA 010011000000B+STATUS+256*(LABEL>>10) LIST W=1 ;For MPALC/PICALC, make this an "E=2". GOTO LABEL LIST W=0 ;For MPALC/PICALC, make this an "E=1". ENDM ------------------------------ 6) Attributions Thanks are due to the following who have contributed to this documention. Jory Bell Don Lekei <72677.2623@compuserve.com> Eric Smith Jeff Dague Steven M. Davidson Ian King kalam ? David B. Thomas Martin Vuille Alasdair MacLean Andrew Tucker Nigel Ballard Timothy McDonough Len Umina Hank Riley Siegfried Grob Andrew M Errington Henri Schultze Tom Mornini Lance Walley Christer Johansson NOTE: .......If your name should be here, apologies. Let me know ! ------------------------------ Disclaimer: Inclusion of any code samples in this document does NOT imply any approval or guarantee as to the suitability of said samples for any purpose whatsoever other than as a self-training aid. I.E. If it blows your ICE, trashes your hard disc, wipes your backup, burns your building down or just plain don't work, #### IT AIN'T MY FAULT #### In the event of judicial ruling to the contrary, any liability shall be limited to the sum charged on you by me for the aforementioned document OR nothing, whichever is the lower. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Except where otherwise stated, this document Copyright (c) 1994,95 by T.A.Kellett, [T.A.K.DesignS Warrington UK ] all rights reserved. This FAQ may be posted to any USENET newsgroup, on-line service, or BBS as long as it is posted in its entirety including this copyright statement. This FAQ may not be distributed for financial gain. This FAQ may not be included in commercial collections or compilations without express permission from the author(s). _______________________________________________________________________________ Tom Kellett < Tom@takdsign.demon.co.uk > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~