microcontroller-faq/PIC

Archive-name: microcontroller-faq/PIC
Posting-Frequency: Monthly
Last Modified: 29 Jun 1995  01:27:23 GMT

microcontroller-faq/PIC
This Version Produced: 30 Jul 1995  01:06:03 GMT
Last Modified: 29 Jun 1995  01:27:23 GMT
The following topics are addressed:

	    0  )  Index	<You're reading it>

	    1.0)  ABOUT THIS FAQ
	    1.1)  Who put this FAQ together?
	    1.2)  How can I contribute to this FAQ?
	    1.3)  What newsgroups will this FAQ be posted to?
	    1.4)  Mailing lists of interest to PIC wranglers
	    1.5)  Other FAQs of possible interest
	    1.6)  Can I distribute this FAQ or post it somewhere else?

	    2.0)  ABOUT THE PIC 
	    2.1)  The PIC micro controller
	    2.2)  PIC variants
	    2.3)  PIC contacts and representatives

	    3.0)  PIC Utilities
	    3.1)  FTP sites for the PIC
	    3.2)  BBSs that support the PIC
	    3.3)  Programming languages (3rd Party)
	    3.4)  Programming hardware  (3rd Party)
	    3.5)  Programming Hardware (D.I.Y.)

	    4.0)  PIC DOCUMENTATION
	    4.1)  Periodicals that cover the PIC
	    4.2)  Books on the PIC
	    4.3)  Miscellaneous documentation on the PIC

	    5.0)  Notes for programmers
	    5.1)  Useful Code Routines [Index]

	    6.0)  Attributions


------------------------------

1)  ABOUT THIS FAQ

------------------------------

1.1)  Who put this FAQ together?

	Many moons ago, on an internet far away, the cry went out out;

	"Lo, seekers of wisdom abound and verily there is a plethora of sources
	with information to impart, but alas, the references to the relevant
	incantations and significant associations of discrete components are
	widespread throughout the land and obfuscated by dissemination....
	What we need is an idiot^H^H^H^H^H, er, champion to sally forth and
	tidy these Augean stables. [own shovel required]"

		Your humble scribe heard the cry and thought "Hey, while I'm growing
	this beard, I've got *bags* of spare time. I mean, not shaving must
	save *hours* a month. I'll give it a try."
		[Filed under..yet another triumph for enthusiasm over experience.]

The boring version;

	I had been lurking on the PIC mailing list for a while, when Jory Bell
	asked if anyone would care to sort through the info he had archived and
	produce an FAQ file from it and I volunteered, thinking that as the list
	was relatively low-volume there would not be much involved.
	Hah !

	If you like it, good ! Drop me a line.

	If not, write and tell me what changes you would like to see.


------------------------------

1.2)  How can I contribute to this list?

    Please, if you have any suggestions corrections or additions,
    notify me by E-MAIL.  :  Tom@takdsign.demon.co.uk   Thank you.

------------------------------

1.3)  What newsgroups will this FAQ be posted to?

This FAQ will be posted to the following newsgroups:
	sci.electronics
	comp.robotics	
	comp.realtime
	sci.answers
	comp.answers
	news.answers

Archive:  rtfm.mit.edu :  <plus all mirror sites>
        /pub/usenet/comp.answers/microcontroller-faq/PIC
        /pub/usenet/sci.answers/microcontroller-faq/PIC
        /pub/usenet/news.answers/microcontroller-faq/PIC

    And the PIC mailing list.

    The schedule for posting will be monthly


------------------------------

1.4)  Mailing lists of interest

	To subscribe to the PICLIST mailing list;
	Mail to:	listserv@mitvma.mit.edu
	Header:		() leave blank, not used.
	Text:		SUBscribe PICLIST	to subscribe
		or	UNSUBscribe PICLIST	to un subscribe
		or	HELP		to get help
		or	INFO REFCARD    for a listserve reference card

	The pic list address is: PICLIST@mitvma.mit.edu

	To receive the mailing list as a digest, send a message to the

			listserv@mitvma.mit.edu 

In the body of the message have the single line:

			SET PICLIST DIGEST


------------------------------

1.5)  Other FAQs of possible interest

Other Microcontroller FAQs

      Subject:  8051 microcontrollers
      Newsgroups:  comp.realtime
                   comp.robotics
                   sci.electronics
      Archive:  rtfm.mit.edu :  <plus all mirror sites>
                /pub/usenet/comp.answers/microcontroller-faq/8051
                /pub/usenet/sci.answers/microcontroller-faq/8051
                /pub/usenet/news.answers/microcontroller-faq/8051
      Maintainer:  Russ Hersch
		Email:  sibit@datasrv.co.il

      Subject:  68hc11 microcontrollers
      Newsgroups:  comp.realtime
                   comp.robotics
                   sci.electronics
      Archive:  rtfm.mit.edu :  <plus all mirror sites>
                /pub/usenet/comp.answers/microcontroller-faq/68hc11
                /pub/usenet/sci.answers/microcontroller-faq/68hc11
                /pub/usenet/news.answers/microcontroller-faq/68hc11
      Maintainer:  Russ Hersch
		Email:  sibit@datasrv.co.il

      Subject:  Microcontroller primer and FAQ
      Newsgroups:  comp.sys.intel
                   comp.realtime
                   comp.robotics
                   sci.electronics
                   alt.comp.hardware.homebuilt
      Archive:  rtfm.mit.edu :  <plus all mirror sites>
                /pub/usenet/comp.answers/microcontroller-faq/primer
                /pub/usenet/sci.answers/microcontroller-faq/primer
                /pub/usenet/news.answers/microcontroller-faq/primer
      Maintainer:  Russ Hersch
                Email:  sibit@datasrv.co.il


    Additional FAQs of interest

      Subject:  Robotics
      Newsgroups:  comp.robotics
      Maintainer:  Kevin Dowling
						 (412)268-8830
                   Email:  nivek@ri.cmu.edu
                   Smail:  Carnegie Mellon University
                           The Robotics Institute
                           Pittsburgh, PA 15213

      Subject:  Electronics
      Newsgroups:  sci.electronics
      Comments:  There are a number of FAQs available in this newsgroup
                 on various subjects.  Among some of the subjects covered
                 are:  LCDs, stepper motors, etc.

      FAQ subject:  Real-time
      Newsgroups:  comp.realtime, comp.answers, news.answers
      Archive:  rtfm.mit.edu : pub/usenet/comp.realtime
      Maintainer:  Mark Linimon
                       Lonesome Dove Computing Services
                       Roanoke, Virginia
                   Email:  linimon@nominil.lonesome.com.

      Subject:  Motorola 68K microprocessor line
		Newsgroups:  comp.sys.m68k
      Archive:  bode.ee.ualberta.ca : pub/motorola/general
                ftp.luth.se : /pub/misc/motorola/faq
                file name of archive is m68kfaq?.zip (? is version)
      Maintainer:  Robert Boys - Ontario, Canada
                   Email: r.boys@genie.geis.com
                                 or
                          fboys@uoguelph.ca


For more information on various microcontrollers and their features,
refer to the Microcontroller primer and FAQ listed above.


------------------------------

1.6)  Can I post this FAQ to my local BBS?

    I am putting no restrictions on the use of this FAQ but please, 

* * * * * * * * *  SEE COPYRIGHT NOTICE AT END OF FAQ * * * * * * * * * * * 

	REMEMBER ! If you choose to upload this FAQ to any BBS or ftp site, 
	then *YOU* are responsible for updating it regularly.

	Otherwise, I'LL TELL YOUR MOTHER WHAT YOU DID !! ;-)

------------------------------

2.0)  ABOUT THE PIC micro controller

    The PIC series are eprom based 8-bit micro controllers
	developed by Microchip Technology

------------------------------

2.1)  The PIC micro controller

Back in 1965, GI formed a Microelectronics Division, and indeed used this 
division to generate some of the earliest viable EPROM and EEPROM memory 
architectures. As you may be aware, the GI Microelectronucs Division were 
also responsible for a wide variety of digital and analog functions, in the 
AY3-xxxx and AY5-xxxx families.

GI also generated a 16 bit microprocessor, called the CP1600, in the early 
70s. This was a reasonable microprocessor, but not particularly good at 
handling i/os. For some very specific applications where good i/o handling 
was needed, GI designed a Peripheral Interface Controller (or PIC for short), 
in around 1975. It was designed to be very fast, since it was i/o handling 
for a 16 bit machine, but didn't need a huge amount of functionality, so its 
microcoded instruction set was small. Hopefully, you can see what's 
coming....yes, the architecture designed in '75 is substantially the PIC16C5x 
architecure today. Granted, the1975 version was manufactured in NMOS, and was 
only available in masked ROM versions, but still a good little uC. The 
market, however, didn't particularly think so, and the PIC remained designed 
in at a handful of large customers only.

During the early 80s, GI took a long hard look at their business, and 
restructured, leaving them to concentrate on their core activities, which is 
essentially power semiconductors. Indeed they are still doing this very 
successfully now. GI Microelectronics Division became GI Microelectronics Inc 
(a wholly owned subsidiary), which in 85 was finally sold to venture capital 
investors, including the fab in Chandler, Arizona.  The venture capital 
people took a long hard look at the products in the business, and got rid of 
most of it - all the AY3- and AY5- parts and a whole bunch of other stuff, 
leaving the core business of the PIC and the serial and parallel EEPROMs and 
the parallel EPROMs. A decision was taken to restart the new company, named 
Arizona Microchip Technology, with embedded control as its differentiator 
from the rest of the pack.

As part of this strategy, the PIC165x NMOS family was redesigned to use one 
of the other things that the fledgling company was good at, i.e. EPROM - the 
concept of the CMOS based, OTP and eraseable EPROM program memory PIC16C5x 
family was born.

Contributed by Alex R. Baker <alex@microchp.demon.co.uk>

Actually, the PIC architecture was first integrated by Signetics for a
company in San Jose (Scientific Memory Systems as I recall) using Bipolar
technology and dubbed the 8X300.
 
Prior to that, the architecture had been a scientific curiosity since its
invention by Harvard University in a Defense Department funded competition
that pitted Princeton against Harvard.
 
Princeton won the competition because the MTBF of the simpler single memory
architecture was much better, albeit slower, than the Harvard submission.
With the development of the transistor and IC's the Harvard Architecture is
finally coming into its own.
 
Microchip has made a number of enhancements to the original architecture,
and updated the functional blocks of the original design with modern
advancements that are in concert with existing architectural processes and
enabled by the low cost of semiconductors.

Contributed by  Len Umina <umina@kirk.mchip.com>


------------------------------

2.2)  PIC Variants

PIC processors are available in three families, which Microchip refers to as
the PIC16C5x, PIC16Cxx, and PIC17Cxx families.

PIC16C5x: 12 bit program word size, 33 instructions, 2 level stack,
          no interrupts

            Program    Data              Max.   Voltage   Typical   Digikey
            memory     memory     I/O    freq.  Range     Current   Price  
            (words)    (bytes)    pins   (MHz)  (Volts)   (mA)      (US $) 
----------  ---------  ---------  -----  -----  --------  -------   -------
PIC16C54     512       25         12     20     2.5-6.25    2        4.39
PIC16C54A    512       25         12     20     2.5-6.25    2        
PIC16CR54    512 ROM   25         12     20     2.0-6.25    1        
PIC16CR54A   512 ROM   25         12     20     2.0-6.25    1        
PIC16C55     512       24         20     20     2.5-6.25    2        5.44
PIC16C56    1024       25         12     20     2.5-6.25    2        5.03
PIC16C57    2048       72         20     20     2.5-6.25    2        6.24
PIC16CR57A  2048 ROM   72         20     20     2.0-6.25    1        
PIC16C58A   2048       73         12     20     2.5-6.25    1        


PIC16Cxx: 14 bit word size, 35 instructions, 8 level stack

            Program    Data              Max.   Voltage   Typical   Digikey
            memory     memory     I/O    freq.  Range     Current   Price  
            (words)    (bytes)    pins   (MHz)  (Volts)   (mA)	    (US $) 
----------  ---------  ---------  -----  -----  --------  -------   -------
PIC16C61    1024       36         13     20     3.0-6.0      ?         ?
PIC16C64    2048       128        33     20     2.0-6.0     3       11.05
PIC16C65    4096       192        ?      20        ?         ?         ?
PIC16C71    1024       36         13     16     3.0-6.0     2       14.38
PIC16C73    4096       192        ?      20        ?         ?         ?
PIC16C74    4096       192                                          
PIC16C84    1024 EE    36 + 64 EE 13     10     2.0-6.0     2       10.15

PIC16C61 (18 pin DIP, 18 pin SOIC) available now?
PIC16C65 (40 pin DIP, 44 pin PLCC) under development
PIC16C73 (28 pin DIP, 28 pin SOIC) under development

PIC17Cxx: 16 bit word size, 55 instructions, 16 level stack:

            Program    Data              Max.   Voltage   Typical   Digikey
            memory     memory     I/O    freq.  Range     Current   Price  
            (words)    (bytes)    pins   (MHz)  (Volts)   (mA)	    (US $) 
----------  ---------  ---------  -----  -----  --------  -------   -------
PIC17C42    2048       256        33     25     4.5-5.5     6       15,15
PIC17C44    8192       480        33     25                         


Notes:

1.  Program memory is EPROM unless otherwise noted.
2.  Data memory is number of usable bytes, not including special function
    registers.
3.  Digikey prices are quantity 10 prices for 4 MHz DIP packaged OTP parts
    with RC oscillator option (where applicable), except that the 16C84 uses
    EE PROM program memory, and the slowest speed 17C42 is rated at 16 MHz.
4.  Prices are from Digikey catalogue number 943 for May/June 1994.
    Other distributors often have lower prices, but typically also have
    high minimum order requirements.  Digikey also usually has plenty of
    parts in stock.  Windowed EPROM parts cost substantially more.

------------------------------

2.3)  PIC contacts and representatives	

I don't know what Country these are in for sure.

    ED Teck. Pubs                                       tel:407-454-9905
    Fred Eady                                           BBS:407-454-3198
    Writes articles for popular magazines.
    Has a PIC programmer kit for $70.


    Protel                                              tel:1-800-544-4186
    Builder of EASYTRAX, which is a free-ware           bbs:1-408-243-0125
    PCB drawing Package
    Call Ext 225 ask for Louise Markham.   


..............................
Australia
    Microchip Technology                                tel:61 03 890 0970
        Product information

    HarTec Limited                                      tel: (03) 268 9000
    205a Middleborough Road                             fax: (03) 899 0819
    Box Hill, Victoria
    3128
        Distributor

    MicroZed Computers                                  tel:61 67 722 777
      296 Cook's Road                                   fax:61 67 728 987
      Armidale, NSW
      2350
        Stamp Products

    Technology Affair                                   tel:61 9 246 4810
    Carine, WA                                          fax:61 9 246 4809
        Pic Tools
..............................
Austria
    Wilke Technology                                    tel:49 241 15 4071
    Aachen                                              fax:49 241 15 8475
        Stamp products
..............................
Belgium
    G.S.E.                                              tel:32 41 77 51 51
    Soumagne                                            fax:32 41 77 53 53
        Stamp Products
..............................
Canada
    Aerosystems International                           tel:514 336 9426
    St. Laurent Quebec                                  fax:514 336 4383
        Stamp Products
        
    AP Circuits                                         BBS 1-403-291-9342
 
    Can download EASYTRAX(V2.06), various utilities, GERBER file 
    proofers, etc. You can upload PCB files and they will make 
    boards and ship to you in about week. (about $100)

..............................
Czech Republic
    MITE                                                tel:42 49 5813 252
    Hradek Kralove                                      fax:42 49 5813 260
        Stamp Products
        
..............................
Denmark
    High Tech Horizon
    Asbogatan 29 C                                      fax: +46 431 108 81
    S-262 51 Angelholm                      e-mail: cj@aristotle.algonet.se
    SWEDEN
    WWW   : http://www.algonet.se/~cj/catalog.html
        Stamp Products
..............................
Finland
    High Tech Horizon
    Asbogatan 29 C                                      fax: +46 431 108 81
    S-262 51 Angelholm                      e-mail: cj@aristotle.algonet.se
    SWEDEN
    WWW   : http://www.algonet.se/~cj/catalog.html
        Stamp Products
..............................
France
    Arizona Microchip Technology SARL                   tel:33 01 6930 9090
    2, Rue Du Buisson aux Fraises                       fax:33 01 6930 9079
    F-91300 Massy, France
    Product information    

    Selectronic                                         tel:33 20 52 98 52
    Lille Cedex                                         fax:33 20 52 12 04
        Stamp Products
..............................
Germany
    Arizona Microchip Technology GMBH                   tel:49 089 609 6072
    Alte Landstrasse 12-14                              fax:49 089 609 1997
    D-8012 Ottobrunn, Germany
    Product information    

    Arizona Microship Technology GmbH                   tel:~49-89-627-144-0
    Gustav-Heinemann-Ring 125                           fax:~49-89-627-144-44
    Munich
    D-81739
    Sales Office for Central & Eastern Europe.
    Area Sales Manager is Mr. W.R. Hollon.

    Wilke Technology                                    tel:49 241 15 4071
    Aachen                                              fax:49 241 15 8475
        Stamp products

    Metronik GmbH
    Leonhardweg 2                                       Tel: +49 89 61108 0
    D-82008 Unterhaching                                Fax: +49 89 6117686

    Rutronik GmbH
    Industriestrasse 2                                  Tel: +49 7231 8010
    D-75228 Ispringen                                   Fax: +49 7231 82282

    Semitron W. Roeck GmbH
    Im Gut 1                                            Tel: +49 7742 8001 0
    D-79790 Kuessaberg                                  Fax: +49 7742 6901

    Future Electronics Deutschland GmbH
    Postfach 1152                                       Tel: +49 89 95727 0
    D-85765 Unterfoehring                               Fax: +49 89 95727 173

..............................
Greece
    Peter Caritato & Associates                         tel:30 1 902 0115
    Athens                                              fax:30 1 901 7024
        Stamp Products
        
..............................
Hong Kong
    Microchip Technology Inc.                           tel:852 410 2716
    Unit No. 2520-2525                                  fax: 852 418 1600
    Tower 1, Metroplaza
    Hing Fong Road, Kwai Fong
    N.T., Hong Kong
    Product information

..............................
Hungary
    HUMANsoft                                           tel:36 1163 2879
    Budapest                                            fax:36 1251 3673
        Stamp Products
        
..............................
India
    AL Systems                                          tel:91 422 232 561
    Coimbatore                                          fax:91 422 213 849
        Stamp Products
        
..............................
Israel
    Elina Electronic Ltd                                tel:972 3 498 543
    Tel Aviv                                            fax:972 3 498 745
        Stamp Products
        
..............................
Italy
    Microchip Technology                                tel:39 039 689 9939
    Product information
    No further information is available at this time

..............................
Japan
    Microchip Technology International Inc.             tel:81 45/471-6166
    Shinyokohama Gotoh Bldg. 8F, 3-22-4                 fax:81 45/471-6122
    Shinyokohama, Kohoku-Ku, Yokohama-Shi
    Kanagawa 222 Japan
    Product information        

    Akizuki Denshi Tsusho Ltd                           tel:81 3 3251 1779
    Tokyo                                               fax:81 3 3432 4492
        Stamp Products
..............................
Korea
    Microchip Technology                                tel:82 2 518 8181
    Product information
    No further information is available at this time

..............................
Netherlands
    Antratek                                            tel:31 1803 17666
    Nieuwerkerk A/D ljssel                              fax:31 1803 16664
        Stamp Products
..............................
Norway
    High Tech Horizon
    Asbogatan 29 C                                      fax: +46 431 108 81
    S-262 51 Angelholm                      e-mail: cj@aristotle.algonet.se
    SWEDEN
    WWW   : http://www.algonet.se/~cj/catalog.html
        Stamp Products
..............................
Portugal
    DIGICONTROLE                                        tel: 351-1-80 57 30
    Av. Eng. Arantes e Oliveira 5 2D                         351-1-848 4542
    OLAIAS 1900 LISBOA                                  fax: 351-1-849 0373
    Electronic Distributor, including PIC's

..............................
Singapore
    Microchip Technology                                tel: 65 222 4962
    Product information
    No further information is available at this time

..............................
South Africa
 
   PACE Electronic Components                           tel:011-9741211 (JHB)
    Microchip  (official agent)


    Jakanaka                                            tel:27 11 907 8475
    Alberton                                            fax:27 11 907 9426
        Stamp Products
        
..............................
South Korea
    Prochips                                            tel:82 2 849 8567
    Seoul                                               fax:82 2 849 8659
        Stamp Products
        
..............................
Switzerland
    Wilke Technology                                    tel:49 241 15 4071
    Aachen                                              fax:49 241 15 8475
        Stamp products
        
..............................
Sweden
    High Tech Horizon
    Asbogatan 29 C                                      fax: +46 431 108 81
    S-262 51 Angelholm                      e-mail: cj@aristotle.algonet.se
    SWEDEN
    WWW   : http://www.algonet.se/~cj/catalog.html
        Stamp Products
..............................
Taiwan    

    Microchip Technology                                tel:886 2 760 2028
    Product information
    No further information is available at this time

    United Tech Electronic Corp.                        tel:886 2 647 1978
    Taipei Hsien                                        fax:886 2 648 1895
        Stamp Products
        
..............................
U.K.    
    Arizona Microchip Technology Ltd                    tel:44 062-885-1077
    Unit 3, Meadow Bank, Furlong Rd                     fax:44 062-885-0178
    Bourne End, Bucks SL8 5AJ
    Product information        

    Eiger Technologies Ltd.,                            tel.44 0928 579009
    14 Howard Court,                                    fax.44 0928 579123
    Manor Park, Runcorn, Cheshire, WA7 1SJ
    Microchips 'Official' UK Distributors

    Hawke Components Ltd.,                              tel.44 0256 880800
    26 Campbell Court,                                  fax.44 0256 880325
    Bramley, Nr Basingstoke, Hants RG26 5EG
    Microchips 'Official' UK Distributors

    Milford Instruments                                 tel:44 977 683 665
    South Milford, Leeds                                fax:44 977 681 465
        Stamp Products
        
    Polar Electronics Ltd.,                             tel.44 0525 377093
    Cherrycourt Way,                                    fax 44 0525 853070
    Leighton Buzzard, Bedfordshire    LU7 8YY
    Microchip 's 'Official' UK Distributors
    Contact for details of the PIC Owners Club

..............................
U.S.    


    Bell Industries                                     tel:1-800-525-6666
    Maryland,                                               1-800-274-6953
    Columbia
       Electronic Distributor, including PIC's 

    Digi-Key                                            tel:800 344 4539
    Thief River Falls, Minnesota                        fax:218 681 3380
        Stamp Products and general parts

    FAI                                                 tel:1-800-303-5701
    Ask for Chris
    Electronics distributor, carry PIC's,

    Link Computer Graphics                              tel:301-994-6669
    Programmer    CLK-3100    
    No further information is available at this time

    Micro Engineering Labs                              tel:(719) 520-5323
    makes PIC-Proto boards

    Myriad Development                                  tel:(303) 692-3836
    CCS - C compiler
    tel: (414) 781-2794 extension 30

    Micro Engineering Labs                              tel:719-520-5323
    Box 7532 Colorado Springs, CO 80933
    Has proto-type boards and demo kits,
    Good source of info, can do manufacturing, etc

    Microchip Technology Inc.                           tel:(602) 786-7200
    2355 West Chandler Blvd.                            fax:(602) 899-9210
    Chandler, AZ 85224-6199
    Product information        

    Needham Electronics                                 tel:(916) 924-8037
     I don't know if they make PIC stuff,               fax:(916) 972-9960
    but they make an EPROM programmer, the PB-10        bbs:(916) 972-8042

    Their emp-20 is great for Pics,Pals,Gala,EEproms etc but is ~$500
    It can be set to auto program on start up. It takes about 4 seconds
    for a bat file to reassemble the source with new EQU's from the
    command line, recompile and program a part.

    Parallax Inc. <ftp.parallaxinc.com>
    3805 Atherton Road, Ste. 102                        fax:(916) 624-8003
    Rocklin, CA 95765 USA                               bbs:(916) 624-7101
    Stamp Products                                      Help 916-624-8333
	A selection of development tools for PIC microcontrollers,
	including assemblers, simulators, C compilers, programmers, in-circuit
	emulators.  All tools run on IBM PC computers.
	Also the "RC"and "JW" versions of the PICs and prototyping boards.

    e-mail address, info@parallaxinc.com
                    orders@parallaxincom

    FTP URL ftp://ftp.parallaxinc.com/pub/

    WWW URL http://www.parallaxinc.com.


------------------------------

2.4)  
------------------------------

3)  PIC Utilities
 
        PICSTART-16B-1
 
Features
        Supports only 16C5x, 16C71, and 16C84
        comes with chips to play with.
        has a zif socket
 
        software includes an assembler with powerful macro capabilities
        and a powerful debugger (both support INHX8M, INHX8S, and INHX16
        file formats)
 
 
        PICSTART-16C
 
Features
        Same as 16B except *only* for 16C64 and 16C74.

------------------------------

	PARALLAX
	--------
Features
	Parallax's own instruction set  Their assembler takes either the
	standard instructions or parallax 's 8051-like pseudo instructions.
	needs only a 360k floppy, MS DOS 2.1, 128K RAM, mono.
	simulator software.
	These assemblers work with many other programmers.
    PASM (5x), PASMX (xx), & PSIM, the emulator, are available free,
    via the BBS, FTP & WWW sites.


------------------------------

3.1)  FTP sites for the PIC

	FTP  SITE		Directory

	ftp.ultranet.com	/biz/mchip
	alias ftp.ultranet.com/microchip
	This is Microchip's own  FTP site

Mirrored on;
	ftp.mrc-bbc.ox.ac.uk	/pub/microchip

The web address is http://www.ultranet.com/microchip
	http://www.ultranet.com/biz/mchip also works

Parallax's ftp site for stamp and pic files
	ftp.parallaxinc.com

WWW URL http://www.parallaxinc.com.
 
	ftp.funet.fi (nic.funet.fi)	 /pub/microprocs/PIC

	wpi.wpi.edu	/stamp

	ftp.luth.se /pub/misc/microchip

	ftp.oak.oakland.edu

	ftp.uni-erlangen.de, 
	directory 
	[ /mounts/epix/public/pub/Multimedia/VideoCrypt
	/microcontroller/microchip.bbs ]
	Maintained by:
	Markus Kuhn <mskuhn@cip.informatik.uni-erlangen.de>

A new www page has been established by Andrew M. Errington;

    http://www.lancs.ac.uk/people/cpaame/pic/pic.htm

The PIC page can be accessed directly or from:

    http://www.lancs.ac.uk/people/cpaame/cpaame.htm

Both pages are 'under construction' and may include references to things
that don't exist, as yet.

------------------------------

3.2)  BBSs that support the PIC

	Microchip BBS
		Contact by dialling the same number you would use to get to
	Compuserve at 19200,n,8,1, except that you press +<CR> at the 
	(garbage) prompt, followed by MCHIPBBS as the host (instead of CIS).
 

	Don Lekei BBS
	    (Canada)    (604) 597-3479

    Parallax BBS,
        (U.S.)      (916) 624-7101.

------------------------------

3.3)  PIC programming languages (3rd Party)

Host m/c        PC

Prog. Name    ASPIC    Shareware PIC assembler  (reg = $100 CDN ($69 US))
        **DESIGNED** for embedded controller design
        the shareware license has an unusual clause absolving 
        those who only use it for non-commercial purposes

Supplier/Author    Don Lekei  < 72677.2623@compuserve.com >
        BBS at (Canada) (604) 597-3479 

Features    - One assembler for 16c5X, 16c6X, 16c7X, 16c8X, 17c42
        - Compatible with PICSIM (MPSIM)
        - Compatible with MAKE, and with auto-error tracking editors
        - Many times faster than PICALC (MPALC)
        - Standard base notation (Intel & Motorola format)
        - CODE and FUNCTION macros
        - Auto register bank management
        - Text/data translation
        - Automatically generates RETLW tables for text / data tables
        - Built-in version management and assembly control functions
        - user command-line switches
        - many other features
        -character set translation (eg. for LED,LCD,On Screen Displays)
        - bit labels, environment labels, etc.

..............................
Host m/c    PC i386 /MS DOS/SunOS 4.1.1/NeXTSTEP 3.0.

Name    B.LO.C release 1.0, version 4.0
        Available for the PIC16CXX and PIC17CXX
Supplier
        Butterfly Signal Processing Inc.
        131 Bloor Street West #200-154
        Toronto, Ontario, Canada M5S 1R8
        TEL: +1.416.929.5754 
        FAX: +1.416.968.7492
Features
        `C-like' syntax
        Locally optimal code generation
        Superfast, one-pass compilation
        Zero stack and memory space used
        Produces fully annotated, easy-to-read assembly code to facilitate
        simulation
        Regular and in-line functions supported
        B.LO.C and assembly routines can be mixed 
        In-line assembly code inclusion
        For more information contact Anees Munshi
        asm@kalam.butterfly.com <may bounce>
        butterfly!asm@kanchenjunga.eecg.toronto.edu   
        asm@eecg.toronto.edu                         

..............................
Host m/c        Macintosh 

Prog. Name    uASM

Supplier
         Micro Dialects Inc,
         PO Box 190,
         Loveland, OH 45140,
         Ph: 513/271-9100.

Features:
        An integrated text editor, assembler
        and communications modules. fully supports macros,
        automatic labels, local labels, conditionally assembly,
        includes to 10 level deep.
        The editor supports up to 10 open files at a time, full
        search and replace including grep searches,
        file size limited only by RAM available.  
        The emulator supports data transfer up to 38,400 baud.

NOTE:   The uASM code is incompatible with the MicroChip Simulator
        <unless you know better ? >

..............................
Host m/c        PC ?

        C5x compiler C5x series
        C71 compiler

Features
        -libraries for RS232 serial I/O and precision delays
        -allow call trees deeper than the hardware stack
Supplier
        CCS                                           414-781-2794  ext.30
        PO Box 11191
        Milwaukee, WI  53211
        (you leave your message on an answering machine)
Also from
    Parallax Inc. <ftp.parallaxinc.com>                 fax:(916) 624-8003
    3805 Atherton Road, Ste. 102                        bbs:(916) 624-7101
    Rocklin, CA 95765 USA                               Help 916-624-8333



Byte Craft Limited supply a C compiler for the PICs. A demo version for
the 17C42 is available ( assembly file generation only ).
MPC.ZIP <ftp.parallaxinc.com>
pricing:
        GBP 695 / GBP 660 for members of the PIC owners club.
        $795(US)
Contact:
        Byte Craft Ltd.,                             tel. (519) 888 6911
        421 King Street North,                       fax (519) 746 6751
        Waterloo,
        Ontario,
        Canada N2J 4E4
        
In UK   Pentica Systems Ltd.,                        tel. (44) 0734 792101
        Oaklands Park,                               fax  (44) 0734 774081
        Wokingham,
        Berkshire RG11 2FE
        England

Also from
    Parallax Inc. <ftp.parallaxinc.com>              fax:(916) 624-8003
    3805 Atherton Road, Ste. 102                     bbs:(916) 624-7101
    Rocklin, CA 95765 USA                            Help 916-624-8333

..............................
Host m/c        PC
name:       PSIM

Software Simulator:     Simulate the PIC's internal operation on the PC.

Supports:   16C5x, 16C71, 16C84.
Features:
    Set breakpoints
    Single-step through code and modify registers
    The simulator also controls the Parallax in-circuit emulators
    [if present]

Filename is PSIM.EXE. on ftp site. <ftp.parallaxinc.com>
Also available PASM and PASMX assemblers.
------------------------------

3.4)  PIC Programming Hardware (3rd Party)

Product     programmer
Model       Microburner 512
Supplier    Baradine Products Ltd,                        tel:604 988-9853
            PO Box 86757,
            North Vancouver, BC CANADA V7L 4L3
Contact     Garry Anderson   <baradine@mindlink.bc.ca>

Features:
        RS-232 terminal serial port compatible programmer
        Supports communications up to 38,400 baud,
        stand-alone or host operation, which can be from a 12VDC battery,
        ie. if you're out at a remote site, standard 6 or 12 volt
        batteries will do (even a car battery, but that's overkill!)


..............................
Product:   emulators from GBP 350
           programmers from GBP 200 
Contact:        
        SMART Communications,                        tel:44 (0)81 441 3890
        2 Field End,                                 fax:44 (0)81 441 1843
        Arkley, Barnet, Herts EN5 3EZ
        England

..............................
Product    Dataman Softy 4
Features:
      With optional PIC module supports entire PIC16/17 range
      Programs all chip specific features
      Supports PICSEE
      Programs from 1 word to whole memory
      Disk of PIC support utilities included
      Supports EPROMS, EEPROMS and Flash upto 8Mbits
      Supports 16 bit EPROMS, EEPROMS and Flash upto 4Mbits
      Supports serial EE 93 and 24 series
      Easy to use
      Free Support via Dataman BBSs in UK and USA
      3 year warranty

Product Information:
The Dataman Softy 4 is the world's best selling handheld programmer. 
With up to 4Mbit of internal memory, S4 can program EPROM, EEPROM and 
FLASH devices of up to 8Mbit and 32 pins without adapters.  The onboard 
serial port can transfer files at up to 115200 baud from a host computer.
S4 also emulates memory devices of up to 4 MBit without additional hardware.
Using the optional PIC adapter set, all current members of the PIC16/17 
family can be programmed. The Softy 4 is compatible with files produced 
by Microchip and third party assemblers. Adapters are also available for 
40 pin EPROMs, serial EEPROMs and 8751.
Others are in preparation.

Contact: Internet: Nigel@dataman.demon.co.uk

Dataman Programmers Ltd                              Tel:44 1300 320719
Station Road,                                        Fax:44 1300 321012
Maiden Newton                                        BBS:44 1300 321095
DORSET DT2 0AE                                       Telex:418442 DATAMN G
United Kingdom

Dataman Programmers Inc.                             Tel: (407) 649-3335
22 Lake Beauty Drive                                 Fax: (407) 649-3310
Suite 101, ORLANDO                                   BBS: (407) 649-3159
FL 32806, USA 

..............................
Product    M2L EZ-EP Programmer and EP-PIC Adapter

Features: Inexpensive - base unit is only $149.95
    PC Parallel port operation With optional EP-PIC adapter,
    supports 16c54,55,56,57,58 16c71, and 16c84
    Programs almost all chip specific features
    Programs from 1 word to whole memory
    Supports EPROMS, EEPROMS and Flash up to 8Mbits
    Adapters available for other microcontrollers and 16bit
    EPROMs
    Free demo software and software updates via      BBS (310/837-7818)
         
Product Information:
The EZ-EP is the world's best programmer for less than $200 (US).  The
base unit programs E/EE/Flash EPROMs from 2716-27080.  The EZ-EP is small
(3" x 6" x 1.5") and light (8 oz) so it is quite portable.  It hooks to a PC
parallel port and adapters are available to do various microcontrollers
and etc. (68hc11, PIC, 8751, 16bit eproms, plcc eproms, serial eeproms).
Fastest programming modes are fully supported.  Programs 27c010 in 23
seconds.

Pricing:
EZ-EP base unit   $149.95
PIC adapter        $49.95  (16c54,55,56,57,58,71,84)
EPLD adapter       $59.95  (ICT 18v8,20v10,22v10)
8751 adapter       $39.95
PLCC adapters      $49.95
16bit adapter      $49.95
8748 adapter       $44.95

Contact: Internet: loving@cs.ucla.edu  -or-
                   M2L.Electronics@f526.n102.z1.fidonet.org

M2L Electronics             (voice 9am-1pm PST)      tel:310 837-7818 
3526 Jasmine #4             (BBS/FAX other hours)
Los Angeles, CA 90034

..............................
PIC16C5x Real-time Emulator        List Price: $599.00US

Advanced Transdata Corp.                             tel: (214) 980-2960
14330 Midway Road                                    fax: (214) 980-2937
Suite 104
Dallas, TX 75244

They also advertise gang programmers, etc. and may have a PIC17C42
product. It's worth a try, maybe, but if no-one tells *me* ? <shrug>

..............................
The Parallax Range

PIC16Cxx Programmer
Supports:       16C5x, 16C64, 16C71, 16C74, and 16C84.
Comes with Parallax and Microchip assemblers, a software simulator
and 18 and 28 pin LIF sockets.
Pricing:
    Programmer (with docs. on disk only)    $99    
Optional
    All cables, psu, and printed docs.      $100 
Adaptors
    18/28-pin ZIF                           $69           
    40-pin ZIF (use with 16C64/74)          $49     
    18/28-pin SOIC                          $129        
    20/28-pin SSOP                          $109        

The BackDraft 17 Programmer
Supports:       17C42.
Comes with Parallax and Microchip assemblers, a software simulator
and 40 pin ZIF socket.
Pricing:
    Programmer                   $199    
Optional
    PLCC adapter                 $129.

In-Circuit-Emulators

The  ClearView '5x Supports:  16C5x  
The  ClearView 'xx Supports:  "newer" PICs (via "personality" modules)

Features:
    Both emulators allow the user to run code in-circuit at speeds
    from 32-kHz to 20-MHz.
    The user can set breakpoints, step through code and modify registers,
    all while the code runs in-circuit.
    The user interface is the same as the software simulator
    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. <ftp.parallaxinc.com>                 fax:(916) 624-8003
    3805 Atherton Road, Ste. 102                        bbs:(916) 624-7101
    Rocklin, CA 95765 USA                               Help 916-624-8333
..............................

Serial Programmer/Demo board for $99 (US) [+carriage]

    Simon Bridger Design; <s.bridger@auckland.ac.nz>    tel:(64) 9 623 4081
    Box 8128 Symonds St                                 fax:(64) 9 623 4082
    Auckland, New Zealand.

    Production Programming (3 voltage) Algorithm
    Serial In-system programming/reprogramming or socket on bd
    Supports 2 different pieces of target hardware from single
        programmers for easy master/slave project development
    Hardware programs any 16cXX parts
        (software currently for 16c84)
    As well as being programmers, they also perform as
       demo-boards with an rs232 port, and come complete with 16C84,    
       preprogrammed, and running a demo program
    Circuits, overlays, code, demos, and BLOC demo etc from: 

    FTP site : ftp://ftp.std.com/pub/simon.bridger

..............................

    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".

..............................
A Design published in ETI (Electronics Today International) magazine

By: Robin Abbott
    37, Plantation Drive
    Christchurch
    Dorset,  BH23 5SG

SPEC: Reads, programs, and verifies PIC 16C54, 55, 56, 57,
    58, 64, 71, 74, 84 and any other upcoming 18, 28, or
    40 pin PIC device which conform to the current PIC
    serial programming specification.
    Reads and programs EEPROM device data areas.
    Fully supports user data area and configuration fuses.
    Serial interface to host PC.
    Windows host software available.
    Loads and saves Intel hex , hex text and binary file
    formats produced by Microchip Assembler (MPPASM).
    Host software supports automatic device serialisation.

Cost to build Approx 35 GBP

This PIC programmer article was published in two parts:
    ETI JUNE  '95 : PIC Programmer Hardware.
    ETI JULY  '95 : PIC Programmer Software.

	ETI (Electronics Today International)
        - programming and construction articles
        - ARGUS SPECIALIST PUBLICATIONS:            tel. : (0442) 66551
        - Argus House, Boundary Way,                fax. : (0442) 66998
        - Hemel Hempstead HP2 7ST,
        - England.
    Overseas & non-newstrade sales by Magazine Sales Department:
    Back Issues available
    Subscription Rates:   (Published Monthly)
    US Dollars Overseas $56.00    Sterling Overseas   31.00GBP
	USA Subscription:
    Wise Owl Worldwide Publications,                tel. : (310) 375 6258
    4314 West 238th Street,                         fax. : (310) 375 0548
    Torrance, CA90505 USA
    Visa/Mastercard orders in USA:
    Pacific Time:   9am  - 9pm Weekdays  10am - 6pm Weekends
    
(If you (can) order the article alone (not the entire magazine) bear )
( in mind that the PCB foils are usually at the back of the magazine,)
( and not in the article itself.                                     )

If you send a blank 16C57XT/16C57JW and a cheque for the sum of 20GBP,
together with a SAE, the author will return the PIC programmed and a
3.5" high density floppy disk with the host software suitable for
Windows 3.1 or 3.11.

..............................

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

	ETI (Electronics Today International)
        - programming and construction articles
        - ARGUS SPECIALIST PUBLICATIONS:            tel. : (0442) 66551
        - Argus House, Boundary Way,                fax. : (0442) 66998
        - Hemel Hempstead HP2 7ST,
        - England.
    Overseas & non-newstrade sales by Magazine Sales Department:
    Back Issues available
    Subscription Rates:   (Published Monthly)
    US Dollars Overseas $56.00    Sterling Overseas   31.00GBP
	USA Subscription:
    Wise Owl Worldwide Publications,                tel. : (310) 375 6258
    4314 West 238th Street,                         fax. : (310) 375 0548
    Torrance, CA90505 USA
    Visa/Mastercard orders in USA:
    Pacific Time:   9am  - 9pm Weekdays  10am - 6pm Weekends

    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 <eric@apache.telebit.com>

------------------------------

5.1) Useful Code Snippets

	5.101)  ZERO THE 16C57 RAM
	5.102)	LONG CALL Macro
	5.103)	LONG GOTO Macro
        5.104)  DATA SWAP TRICK
        5.105)  MULTIPLE PRECISION ADDITION


------------------------------

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

------------------------------

5.104) DATA SWAP TRICK

    by: Mike Keitz <mkeitz@bev.net>

Swapping W with a File (RAM) register (PIC 16Cxx) Sometime you need to swap 
the data in W with that in RAM, a port, or a special purpose register (i.e. 
W<->F).  This may appear to be easy with a few MOV instructions and a 
temporary RAM location, but when you sit down to code it you'll see that 
it'll take *two* temporary locations and 6 instructions to shuffle the data 
around using only MOVs.  So, like many things with a PIC program, an 
unconventional technique can be really useful...  like this:

        XORWF   file,w
        XORWF   file,f
        XORWF   file,w

Try it on paper until you're convinced it will work.  Remember that XORing 
the W+F+F leaves a result of the original value of W (the two xors with the 
same data cancel out, so the final result is W xor 0 = W).  The sequence 
affects the Z flag, of course (one that had a MOVFW in it would as well), but 
not in a particularly useful way.

This will work as-is with a port which is set for all output.  The port will 
be read 3 times, but written to only once during the second instruction. If 
the port has some bits set for input, the result left in W for the input bits 
is probably going to be wrong. (I'll leave it to you to analyze the 
situations when it happens to be right)  A correct read of the input bits can 
be done with a conventional MOVFW after the routine is used to update the 
output bits.

Understanding this, I now present the logical extension: swapping two file
registers.  This is tremendously useful to indirectly index two data sets at
the same time (didn't think that was do-able, eh?)

First, a conventional solution is worth considering:
        MOVFW   FSR         ;(the special purpose register)
        MOVWF   tmp         ;(a temporary location)
        MOVFW   fsr2        ;(a location defined to hold the alternate index)
        MOVWF   FSR
        MOVFW   tmp
        MOVWF   fsr2
        
This is 6 instructions, and requires a temporary location.  If RAM is scarce
in your design (and it probably is, since you want to indirectly index two
data sets at once), consider using the W<->F method above...

The obvious approach is to use the routine above three times, assuming
you wrote it as a macro:
        swapwf  FSR
        swapwf  fsr2
        swapwf  FSR
So this is 9 instructions, but W is not affected, and no temporary RAM is
required.  If you can tolerate losing the value in W while swapping the
files, then this shorter version will also work:
        MOVFW   FSR
        swapwf  fsr2
        MOVWF   FSR
This is a total of only 5 instructions, 1 less than the conventional method.
Allocating a temporary location to store W during the swap would add 2 more.
Everything is a trade-off, I suppose.


------------------------------

5.105) MULTIPLE PRECISION ADDITION

    by: Mike Keitz <mkeitz@bev.net>

This trick concerns multiple precision addition (i.e. 16, 24, etc. numbers)
The ADDWF instruction adds two numbers, and sets the C flag if there is a
carry out.  But there is no instruction that adds W+F+C to carry the carry
throught the higher bytes.  There is an easy work-around for 16 bit numbers:
simply increment one of the numbers before adding if the C bit is set.  This
is adequately detailed in the Microchip application notes, but I'll show it
here for reference:
  
add16   movfw   datal       ;Adds 16 bit number in datal and datah
        addwf   resultl,1   ;to resultl and resulth,
        movfw   datah       ;leaving the result in resultl and resulth
                            ;Following 3 instrs. are a primitive add with
                            ;carry W+F+C -->F.
                            ;C flag may not correctly represent
                            ;carry out of W+F+C
        skpnc               ;If no carry...
        incf    resulth,1   ;If carry, add 1 to result.
        addwf   resulth,1   ;Done.


The problem with this technique is that it cannot be used for numbers larger
than 16 bits because the C flag will not be set properly at the conclusion
of the last 3 instructions.  In particular, if resulth is FF and C is set
going in, C will be incorrectly clear at the conclusion of the operation.
(Don't you wish it was YOU and not your customer who was the first to try
that?) No big problem with the 16 bit add, the result will still be correct,
but the overflow won't be indicated.

The best way around this I could think of was to use this 4-instruction
sequence instead of the 3-instruction one above.  I think there are other
4-instruction sequences that do essentially the same thing. Then a 24, 32,
etc. bit add can be carried out (pun intended?) by using this sequence for
the "middle" bytes.  The faster skpnc/inc/add above can be used for the last
byte if having a proper carry out of the whole operation is not required.  

;     Add W to F with proper carry in and out.
	  skpnc
	  incfsz f,1
	  addwf  f,0
	  movwf  f

Although this has 2 conditional instructions, the execution time is always 4
cycles, if you're counting.  (Another PIC rule of thumb: a skip instruction
and the one after it will always take 2 cycles, unless the instruction
possibly skipped is a goto or call)


------------------------------

6) Attributions

Thanks are due to the following who have contributed to this documention.

    Jory Bell             <jory@mit.edu>
    Don Lekei             <72677.2623@compuserve.com>
    Eric Smith            <eric@apache.telebit.com>
    Jeff Dague            <jpdague@iastate.edu>
    Steven M. Davidson    <davidson@its.bldrdoc.gov>
    Ian King              <iek@arrc.salf.ac.uk>
    kalam ?               <asm@kalam.butterfly.com>
    David B. Thomas       <davidson@its.bldrdoc.gov>
    Martin Vuille         <martin.vuille@synapse.org>
    Alasdair MacLean      <alasdair@aifh.ed.ac.uk>
    Andrew Tucker         <ast@halcyon.com>
    Nigel Ballard         <Nigel@dataman.demon.co.uk>
    Timothy McDonough     <timmed@ns.cencom.net>
    Len Umina             <Umina@Kirk.mchip.com>
                          <Umina@World.std.com>
    Hank Riley            <h1riley@umassd.edu>
    Siegfried Grob        <siegfried.grob@student.uni-ulm.de>
    Andrew M Errington    <a.errington@lancaster.ac.uk>
    Henri Schultze        <henri@fscz-md.boerde.de>
    Tom Mornini           <tmornini@parallaxinc.com>
    Lance Walley          <lwalley@parallaxinc.com>
    Christer Johansson    <cj@aristotle.algonet.se>
    Ed Meyer              <Ed_Meyer@mindlink.bc.ca>
    Simon Bridger         <s.bridger@auckland.ac.nz>
    Fernando Soares       <Fernando.Manuel.Ramos.Soares@uninova.pt>
    Chris Madden          <maddenc@itd1.ul.ie>
    
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 >
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~