PIC Microcontrollers Tutorial- Introduction

The original 8-bit PICs are available for more than a decade now. Many websites still mostly deal with these older PICs.

Sometimes even assembler is introduced, and various serial port programmers can be seen. However, these chips are limited to 20 MHz and have relatively small memories.

In 2007, PIC32 chips have been released for the first time. It is possible to program them in assembler but typically, C language is used. For a while now, MPLABX is available, including C compilers for all PICs (8bit, 16bit, and 32bit).

If data larger than 8bit is used, each line of C needs many instructions, and this limits the complexity of the programs fitting into the FLASH memory.

So the best thing is to start off with PIC32- simply, they have much larger memories. You should examine the three product families on the Microchip website.

If you try the smaller chips, and even assembler, you only loose time. The complexity of the firmware will be limited. I would not recommend the smaller 8bit chips for non-professional usage at all. Not if you don’t know the difference and why you want to use an 8bit chip.

In C language, all PIC firmwares are somehow exchangeable, however, particular differences do exist in some areas, for instance when writing/reading the internal FLASH. In assembler you even get a barrier within a PIC family so you should stay away from it. Actually I did use assembler for some years, but the programs more and more became too difficult to maintain.

There are three main families, as said, 8bit, 16bit, and 32bit.

The 8bit family also is divided quite a bit:

Baseline with a 4MHz limit (these are smaller pincount chips)

Baseline with 20 MHz limit (these don’t have many pheripherals or even no pheripherals)

Midrange (these are the most known 8bit PIC). They do have pheripherals such as serial ports, and A/D.

Extended midrange. These are relatively new PICs with extended instruction set, more RAM, and additional capabilities. If you really want to try 8bit chips, they are more comfortable to use.

18F PICs (Also known as High-end). These also have additional instructions, FLASH write capabilities, larger FLASH, and all 18F PICs do have pheripherals.

16 bit. They became available some time before PIC32. The PIC32 are no longer original PICs, the core is foreign, while the pheripherals do have many similarities to regular PICs.

16 bit PICs can be recognized by either 24F or 30F (also 33F). You should study this brochure to understand about the DSP-like capabilities of these PICs: http://ww1.microchip.com/downloads/en/DeviceDoc/DS-70095K.pdf

PIC32. The instruction set of these chips is fairly complex and so is the memory partitioning. Normally C language is used for these chips. The standard PIC32 has limits of 40, 50 and 80 MHz, and recently a new series with 200 MHz was introduced.

However the 40 MHz PIC32 are not just two times as fast as an 8bit 20MHz PIC. These 8bit chips need many instructions for addressing operations, and maths, while the PIC32 only needs one or a few. 32bit operands or 16bit operands can be executed directly.

A PIC32 is at least 10x times as fast (at the same MHz speed). The FLASH memory and the RAM is disproportional much larger. The price for these chips is only marginally a little higher than for 8bit chips, however, the larger 8bit PICs are also quite expensive.

2

Is it required to use a developement board? It can be helpful, since normally, code examples will be included. But it is not strictly neccessary. You should refrain eventually from building a serial port programmer + using a small 8bit chip together with assembler. Even if it is possible perfectly, and you can write nice applications.

it is possible to scroll text on a LED matrix in assembler. But in the end it is creepy if you want to change it over to a different chip, or change the layout or technique or run it backward.

A complex program in assembler often boils down to a fairly simple C source. But, what if your C source will be highly complex? The assembler code produced by the C compiler will be so lengthy and complex that beginners normally don’t understand much of it anymore.

Don’t be tempted to optimize your program, or to max out the internal RAM and FLASH. If the memory is not large enough, simply use a larger chip. If you need a serial port, get a chip with hardware serial port. If you need two, get a chip with two ports. Yes it is actually possible to do I2C in software and there is nothing wrong with it. But you get the idea.

3

What you need:

Download MPLABX + all the C compilers. If you use PIC 32 or USB or TFT, also download the framework source codes.

Buy a FLASH programmer, this could be the PICKIT3 for a start.

Buy some PIC32 + PCB adapters + supporting components. Alternatively, buy a nice developement board/kit.

Download the relevant datasheets and read them. For the PIC32, there are seperate reference manuals.

Learn C language, from books and/or websites.

Write your first small programs and run them in the MPLAB simulator. By the way, you could use any chip for that, even the 8bit one’s.

Depends what you intend to build, and if you just want to learn, to play around, or if you want to develope something professionally. Get some LED displays, LCD modules, and TFTs.

PICs are fairly simple to use actually. OK the configuration can be hard for the more complex PICs. But often mostly the defaults will work for a start. You don’t even neccessarily needs crystals anymore just to startup the PIC.

You can really buy a PICKIT3 clone, and just one single PIC chip, and one LED 7segment, and run it from USB- and that’s it.

Normally you would want to have a little bit more to play around with I guess. But don’t pay too much attention to the much older 8bit family. If they charge you moon prices for powerful PICs and very high prices even for nearly obsolete 8bit chips, search the internet for alternatives. I mean really don’t become absorbed by this 8bit stuff too much, it was nice some 20 years ago when it was new, but the 32bit technology is better in many aspects.

There are professional usage scenarios for small 8bit chips, but for small-scale circuit production, it gives no advantage. Or maybe you want to exploit some special hardware feature? You want a small 14pins USB controller without need for a crystal?

As I wrote, examine the microchip website, and look again regularily.

Leave a Reply

Your email address will not be published. Required fields are marked *

*