microcontroller-faq/PIC Summary: This article is a collection of information sources for the MicroChip PIC series of microcontrollers This Version Produced: 04 Dec 1995 02:49:39 GMT Last Modified: 04 Dec 1995 02:48:36 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? Tom Kellett TAKDesignS Warrington England [the above is not a postal address, merely a locator] If you like this FAQ; tell people that usenet is a good place. If not, 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.misc comp.arch.embedded comp.realtime And will soon be, once again, archived at; 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 The schedule for posting will be monthly * * 1.4) Mailing lists of interest To subscribe to the PICLIST mailing list; Mail to: firstname.lastname@example.org 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 email@example.com 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: firstname.lastname@example.org 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: email@example.com 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: firstname.lastname@example.org Additional FAQs of interest Subject: Robotics Newsgroups: comp.robotics Maintainer: Kevin Dowling (412)268-8830 Email: email@example.com 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: firstname.lastname@example.org. 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: email@example.com or firstname.lastname@example.org 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. * * 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 <email@example.com> 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 <firstname.lastname@example.org> * * 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 tel: +46 431 41 00 88 S-262 51 Angelholm fax: +46 431 41 00 88 SWEDEN e-mail: email@example.com WWW : http://www.algonet.se/~cj/catalog.html Stamp Products ............................. Finland High Tech Horizon Asbogatan 29 C tel: +46 431 41 00 88 S-262 51 Angelholm fax: +46 431 41 00 88 SWEDEN e-mail: firstname.lastname@example.org 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 tel: +46 431 41 00 88 S-262 51 Angelholm fax: +46 431 41 00 88 SWEDEN e-mail: email@example.com 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 tel: +46 431 41 00 88 S-262 51 Angelholm fax: +46 431 41 00 88 SWEDEN e-mail: firstname.lastname@example.org 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, email@example.com orders@parallaxincom FTP URL ftp://ftp.parallaxinc.com/pub/ WWW URL http://www.parallaxinc.com. * * 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 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 <firstname.lastname@example.org> 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. Eric Smith <email@example.com> Has a www PIC page at: http://www.spies.com/~eric/pic/ * * 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 < firstname.lastname@example.org > 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 email@example.com <may bounce> firstname.lastname@example.org email@example.com ............................. 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. Real-time, in-circuit emulators PIC specific and universal programmers Cross-Assembler, Cross-Compiler Emulation Technology, Inc. tel: (408)982-0660 2344 Walsh Avenue fax: (408)982-0664 Bldg. F Santa Clara, CA 95051 Email: firstname.lastname@example.org WWW: http://www.emulation.com FTP: ftp.emulation.com ............................. * * 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 <email@example.com> 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: firstname.lastname@example.org -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; <email@example.com> 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 ............................. PIC Specific Products; Real-time, in-circuit emulators PIC specific and universal programmers Cross-Assembler, Cross-Compiler Emulation Technology, Inc. tel: (408)982-0660 2344 Walsh Avenue fax: (408)982-0664 Bldg. F Santa Clara, CA 95051 Email: firstname.lastname@example.org WWW: http://www.emulation.com FTP: ftp.emulation.com ............................. 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: email@example.com 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. ............................. Chris B. Sakkas ITU Technologies 3477 Westport Ct. Cincinnati, OH 45248-3026 ITU Technologies is proud to introduce the ITU PIC Programmer Model PIC-1, the first truly low-cost and versatile programmer for the Microchip Family of PIC microcontrollers. This programmer is designed for programming Microchip's popular PIC16C6x/7x/8x family of microcontrollers. The programmer is approximately 3.3" x 3.7" in size and features a built-in 18 pin DIP socket and an expansion header. The expansion header is provided for programming adapters and in-system programming of EEPROM-based PICs. A variety of adapters will also be available to support 28/40 pin PICs and various packaging forms. The PIC-1 programmer comes complete with an interfacing cable to connect to your PC parallel port, programming software, and power supply. The included power supply is for US use only, foreign customers must provide their own converter/power supply. The programming software included is designed to program all of the supported PICs mentioned above. Software updates will be available electronically free of charge. The software allows programming of the PICs program memory, setting of configuration fuses, program verification and the ability to read PIC memory to a file. The software also allows data memory programming, reading of data memory, and bulk erase of EEPROM-based PICs. An UNREGISTERED shareware version of Don Lekei's Macro+ Assembler for Microchip PIC Microcontrollers (ASPIC) is included with each programmer for your evaluation. SPECIAL INTRODUCTORY PRICING FOR INTERNET CUSTOMERS For a limited time, this special introductory pricing is available: ITU PIC Programmer (Model PIC-1) KIT $29 This kit includes: * an easy to follow instruction manual for building your programmer * a high quality printed circuit board with silkscreen * all components needed to build the programmer * PIC Programming Software for IBM PC-compatible Computers * a cable to connect the programmer to a PC's parallel port * a power supply for the programmer (for US use) * a User's manual introducing the PIC-1 programmer and software ITU PIC Programmer (Model PIC-1) Assembled/Tested $49 As above, but assembled and tested. ALSO AVAILABLE PIC-N-GO PACKAGES: PIC-N-GO packages are designed for the microcontroller novice. They include the ITU PIC Programmer Model PIC-1, as above, plus a PIC16C84-04/P microcontroller. This EEPROM-based microcontroller is ideal for the novice and the PIC-N-GO packages are the most attractive programmers available for the beginner. You can program and erase the PIC16C84 many times without the use of an EPROM eraser, making it the best choice for those starting out with microcontrollers. These packages are great for students and hobbyists looking to acquaint themselves with microcontrollers. PIC-N-GO KIT only $39 * includes PIC-1 programmer kit and PIC16C84-04/P microcontroller (w/ data sheet) PIC-N-GO Assembled/Tested only $59 * includes assembled and tested PIC-1 programmer and PIC16C84-04/P (w/ data sheet) Quantity discounts are available, making these packages the perfect choice for schools and clubs wishing to teach introductory microcontroller usage. All products include a 30-day money back guarantee and a 90-day warranty. Due to the nature of kit building, all kits must be returned unassembled to qualify for a full refund. Please e-mail us at ITUTec@aol.com with your questions or if you would like ordering information. pricing: ITU PIC Programmer (Model PIC-1) Kit $29 + $5 Shipping/Handling Assembled and Tested $49 + $5 Shipping/Handling PIC-N-GO Packages (ITU PIC Programmer and one PIC16C84-04/P) Kit $39 + $5 Shipping/Handling Assembled and Tested $59 + $5 Shipping/Handling Ohio Residents please add 5.5% sales tax. Please note that the above is for prepaid orders. COD orders are available, but must include an additional $5 service charge. Please contact us if you require second day or next day delivery. Foreign orders must be prepaid in US funds and include an additional $5 Shipping/Handling fee. Please contact us if you require air parcel or express delivery. We will gladly accept your personal check or money order for payment. Your package will be shipped upon receipt of your payment. Please make your check payable to ITU Technologies. You may place your COD order via e-mail or phone. You must include your phone number along with your address. You can e-mail us at ITUTec@aol.com or phone us at (513) 574-7523 from 9AM to 5PM EDT Monday through Friday. We do prefer orders via e-mail since this allows us to focus our phone use towards technical support. Our web address is: http://www.iglou.com/ITU and our anonymous ftp address is: ftp://iglou.com/members/ITU We also have some files on PC-interfacing and general electronics-related material available via ftp. The support directory will always contain the latest versions of our PIC programmer software. We welcome any user contributed programs to our site. If you would like to share your PIC-related code or utilities with the Internet community, just upload them into our incoming directory and send me an e-mail message with a description of your upload. We would appreciate any comments and suggestions, especially additions or corrections to links on our page. Please keep in mind that we have just added this page and will continue to make updates! .......................... * * 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: firstname.lastname@example.org - $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 email@example.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 <firstname.lastname@example.org> URL http://www.spies.com/~eric/pic/ * * 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 <email@example.com> 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 <firstname.lastname@example.org> 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 <email@example.com> Don Lekei <firstname.lastname@example.org> Eric Smith <email@example.com> Jeff Dague <firstname.lastname@example.org> Steven M. Davidson <email@example.com> Ian King <firstname.lastname@example.org> kalam ? <email@example.com> David B. Thomas <firstname.lastname@example.org> Martin Vuille <email@example.com> Alasdair MacLean <firstname.lastname@example.org> Andrew Tucker <email@example.com> Nigel Ballard <Nigel@dataman.demon.co.uk> Timothy McDonough <firstname.lastname@example.org> Len Umina <Umina@Kirk.mchip.com> <Umina@World.std.com> Hank Riley <email@example.com> Siegfried Grob <firstname.lastname@example.org> Andrew M Errington <email@example.com> Henri Schultze <firstname.lastname@example.org> Tom Mornini <email@example.com> Lance Walley <firstname.lastname@example.org> Christer Johansson <email@example.com> Ed Meyer <Ed_Meyer@mindlink.bc.ca> Simon Bridger <firstname.lastname@example.org> Fernando Soares <Fernando.Manuel.Ramos.Soares@uninova.pt> Chris Madden <email@example.com> 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 > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|file: /Techref/microchip/davidtait/picfaq.txt, 76KB, , updated: 2001/4/17 12:15, local time: 2018/9/18 09:36,
|©2018 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?|
<A HREF="http://www.piclist.com/techref/microchip/davidtait/picfaq.txt"> microchip davidtait picfaq</A>
|Did you find what you needed?|
PICList 2018 contributors:
o List host: MIT, Site host massmind.org, Top posters @20180918 RussellMc, Van Horn, David, Sean Breheny, David C Brown, Bob Blick, Isaac M. Bavaresco, Neil, Denny Esterline, John Gardner, Harold Hallikainen,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
Welcome to www.piclist.com!