|
|
|
The Microchip PIC Microcontroller
|
|
|
|
The PIC microcontroller is manufactured by Microchip. The PIC microcontroller architecture is based on a modified Harvard RISC instruction set. A microcontroller is similar to microprocessor but it additionally contains its own program command code memory, data storage memory, bi-directional (input/output) ports and clock oscillator. Many microprocessors require the use of additional chips to provide these requirements. Microcontrollers are totally self contained. The PIC microcontrollers have two separate data buses, instructions and data are transferred on separate buses, avoiding processing bottlenecks. This increases speed and overall system performance. Two stage pipelining enables one instruction to be executed while the other is being fetched. Single wide-word instructions increases software code efficiency and reduces required program memory. The great advantage of microcontrollers is that they can be programmed to perform many functions for which many other chips would normally be required. There are a few dozen bytes of RAM reserved for variables generated by the program, the amount of RAM varies depending on the PIC type. There is also some “non-erasable” data storage EEPROM, again data storage storage varies depending on the PIC type. Microchip refer to RAM locations as files or registers, The first number of RAM locations have internal registers mapped to them. Microchip refers to them as “Special Function Register” changing these locations with instructions changes the corresponding registers. The remaining RAM locations are used for the programs variables. Microchip refers to them as ‘General Purpose Registers’. PIC’s are manufactured and supplied blank, they need to be programmed, to perform a chosen task. The program consists of a variety of commands. The instructions are in ROM and dedicate the microcontroller to performing tasks one at a time.
|
|
|
|
PIC Varieties
|
|
|
|
There are many families of PIC microcontrollers available, some with low pin count, others with a high pin count. Most can be repeatedly reprogrammed also known as ‘Flash’ devices, making them ideally suited for the hobbyist. The PIC clock rate can range from 4MHz to 20MHz, when using an external crystal, slower clock rates if a resistor capacitor arrangement is used. Other PIC varieties can generate their clock internally, eliminating the use for an external crystal. Latest PIC varieties incorporate one or more internal timers, USART, I2C, and SPI internal hardware modules. As the Microchip microcontroller line grows, the part numbering convention/system seems to be getting a bit involved. The real key is to keep in mind the fundamental groups in terms of how they function and some extent how program code must be written for them. Microchip is now publishing a ‘Product Line Card’ revised quarterly which will inform the users what is current.
|
|
|
|
Programming the PIC
|
|
|
|
A text editor is used to write the program, usually referred to as the source code. The code can be written in PIC assembly language or other high level programming languages such as Basic, C etc.... Once the source code is corrected and assembled the resulting HEX code is downloaded into the PIC via a programmer. Prior to downloading the code into the PIC the program can be tested with a simulator to check that the program performs as it should. The programmer consists of software and hardware, the PIC is plugged on to the hardware which in turn is connected to the PC usually via one of the PC external parallel, serial or USB port. The software is then used to downloads the assembled HEX file (program data) into the PIC. The PIC is now ready to perform its tasks. The Microchip PICkit2 Microcontroller Programmer is a low cost development programmer. It is capable of programming most of Microchips Flash microcontrollers. The PICkit2 Microcontroller Programmer Operating System (firmware) can be easily upgraded from the programming software. New device support can be added by updating the operating system. The latest firmware is available on Microchips web site.
|
|
|
|
The Microchip MPLAB IDE
|
|
|
|
The Microchip Integrated Development Enviroment (IDE) is an application that has multiple functions for software development. MPLAB (IDE) is an executable program that integrates a compiler and assembler, a projet manager, an editor, a debugger, simulator and an assortment of other tools within one window application. A user developing an application should be able to write code, compile, debug an application without leaving the MPLAB (IDE) desktop. It is available for download for free from the Microchip site.
|
|
|
|
|
|
|
|