A small correction:
The PIC10's, PIC12's, PIC16's and PIC18's are 8 bit devices, the PIC24's are 16 bit devices and the PIC32's are 32 bit devices. Microchip has C compilers available for all but the PIC10's, PIC12's and PIC16's.
The older PIC10's (PIC10F2xx)
and MOST PIC12's and a couple of legacy PIC16's (PIC16C5x) have the 12-bit core. (8 bit data, 12 bit wide program memory) and have a very limited instruction set and only two levels of call stack and no data stack.
Some newer PIC10's (PIC10F3xx)
, PIC12's and most PIC16's have the 14-bit core. (8 bit data, 14 bit wide program memory) and have 8 levels of call stack and no data stack.
Some new PIC16's (PIC16F1xxx) and now some PIC12's (PIC12F1xxx)
have the enhanced 14 bit core (8 bit data, 14 bit wide program memory) with an increased instruction set and a 16 level call stack.
The enhanced midrange devices and
PIC18's upwards can manipulate their call stack and do auto inc/dec on their FSR pointers allowing software data stacks.
Microchip has bought HiTech so now has C compilers available for the PIC10/12/16 range. The new Microchip XC 8 compiler is based on the HiTech PIC10/12/16 and PIC18 compilers.
As you are an electronics novice, I STRONGLY recommend starting off with DIL parts that can be plugged in a breadboard. (package types PDIP, SPDIP and PDIP 600mil) The largest part available in DIL has 40 pins. Everything else is surface mount and requires either a full development board or special tools to work with.
(At the minimum a custom made PCB, a fine tipped temperature controlled soldering iron, a good illuminated bench magnifier and an EXTREME level of soldering skill, and at the high end, a full PCB prototyping system, a reflow oven, a hot air rework station with manual vacuum pick and place for part handling, and a binocular microscope.)
The PIC18 chips are far more capable than the PIC16 chips and in many respects less frustrating to program but they tend to have al lot more and more complex built in peripherals.
Your C experience will NOT translate well from a desktop or mainframe environment to small microcontrollers. Although the basic language is the same, all the library functions you are used to will be either totally missing, cut down or radically different. Also due to the many restrictions of the PIC16/18 design, memory is severely limited and dynamic allocation is a really bad idea in at least 99% of all cases. The stack limitations in particular means that parameter passing and local variables are seriously restricted and don’t use the usual method of allocating space from the stack. Unless you have a reasonably good idea of the assembly code your C will compile to, you can use up most of your chip's resources and get in serious trouble with one badly chosen line of 'C'
Although it is possible to program in C++ on a PIC, the limitations are such that you will have to virtually unlearn the language and start over. It offers little advantage if any over ‘C’ that is the de-facto standard for programming embedded medium performance microcontrollers.
In my opinion you need to start by learning the basics of the Midrange architecture (PIC16 14 bit core) and then upgrade to the PIC18 series and C.
All modern PICS can be (and usually are) programmed via a 5 or 6 wire ICSP connection. (Supply, ground, program data, program clock, /MCLR|Vpp and optionally LVP (labelled PGM on pin diagrams). All modern programmers equipped with a socket use these signals and route them to the appropriate pins of the PIC.)#
Nearly all PIC18's and a few PIC16's have in circuit debug support built into them but for ALL PIC10's, PIC12's and most midrange PIC16's if you want to do debugging you need a -ICD or -ICE variant of the chip which has more pins for the ICSP/ICD interface and is only available on an expensive debug header.
The PICkit 3 mentioned above is Microchip's latest entry level programmer/debugger but it is giving a lot of people a lot of trouble. Hopefully the problems will be resolved soon, but
a year now nearly four years
down the line it still isn't 100% 'right'. It is the only entry level choice that supports debugging PIC32 series from MPLAB. Edit: The PICkit 3 situation is much improved as it can now emulate a PICkit 2 with the standalone programming application and now has a debug capable starter kit .
Many users here would still recommend its predecessor the PICkit 2
. Warning: the 'Pickit 2 Starter Kit' includes the 'Low pin count demo board' which does not support debugging unless you buy an expensive debug header and adaptor board (except using a PIC18F14K22 - which is from a different family of PICs and is not included with the kit and the pins required by the debugger conflict with the pot and switch)
The minimum recommended 'kit' to get into PIC programming is a selection of debug capable DIL PICs, a solderless breadboard and a selection of components etc., a regulated, current limited 5 V PSU (optionally: one capable of providing 3.3 V for low voltage PICs and +/- 12 V for analog interface circuits)
and a PICkit 2 (part# PG164120
) + either a home made 6 x 0.1" pitch pin header to individual pins cable to connect the PICkit 2 to your PIC on the breadboard or order AC162069
- MPLAB ICD 2 Breadboard Cable and AC164110
- RJ-11 to ICSP Adapter (which also gives you a ICD 2/3 type RJ-11 connection from your PICKIT 2) N.B. you cant currently debug enhanced midrange parts (PIC12F1xxx or PIC16F1xxx) with a PICkit 2.
If you have a bit of cash to splash, get the PICDEM Lab Development Kit (DM163035)
which has nearly everything you need to get started with baseline and mid-range PICs. It includes
a PICkit 2* plus
all the parts, software and equipment you need to get started except for a Windows PC (32 bit XP recommended, 98SE, 2000, Vista and Win7 are possible),
a 9 V DC 'wall wart' PSU and a digital multimeter. Although the kit is not intended for anything over 20 pins, the solderless breadboard area is generous enough to allow you to venture into using 28 pin parts and selected DIL PIC18's. One debug capable PIC is supplied, a PIC16F88 (which I personally recommend as an entry level PIC as all reasonably well written programs in books and tutorials for the PIC16F84(a) can be ported to it simply by changing the included chip specific header file, the first address used for user ram and initialising two extra registers to turn off its advanced analog features) * Currently the PICDEM Lab kit includes a PICkit 3. If you want a PICkit 2, you may still find a supplier with old stock - just ask them if the programmer pod is black (PICkit 2) or red (PICkit 3) Another alternative is the Gooligum development board which targets the smaller PICs (up to 14 pins) and compliments the popular Gooligum tutorials. It does not support any PIC with built in debuging.
Edit: Updates + spelling corrections (Nov 2010). Small updates (Nov 2011). Updated device family and PICkit 3 info. Added Gooligum board. (current)
post edited by Ian.M - 2012/10/29 16:14:14