Sie sind auf Seite 1von 10

PIC is a family of modified Harvard architecture microcontrollers made by Microchip Technology, derived from the PIC1650[1][2][3] originally developed

by General Instrument's Microelectronics Division. The name PIC initially referred to "Peripheral Interface Controller".[4][5] PICs are popular with both industrial developers and hobbyists alike due to their low cost, wide availability, large user base, extensive collection of application notes, availability of low cost or free development tools, and serial programming (and re-programming with flash memory) capability. They are also commonly used in educational programming as they often come with the easy to use 'pic logicator' software.
The PIC microcontroller is a wonderful device for radio amateurs, allowing a wide range projects to be built using one underlying basic hardware design. The chip manufacturers, Arizona Microchip [1], offer a range of devices for all sorts of applications, ranging from low pin-count devices for simple pushbutton jobs, right the way up to advanced Digital Signal Processing. The mid range Pic 16Fxxx family of devices are probably the most useful to us, as they come in a variety of packages and pin counts, are straightforward to programme, have the same basic processor core, and come with a variety of different peripherals. Analogue to Digital converters, Timer counters, Serial Interface, EEPROM memory, as well as various numbers of Input / Output pins. Some even have integrated USB interfaces. To allow widespread adoption by amateurs and give an introduction to the use of PICs I designed the module described here. A few standard applications have been developed in parallel, with ready programmed PICs offered for a plug-and-play solution. BUT... the fully commented source code for these is all available for free download and you are strongly advised to think about obtaining a PIC programmer and tools and try modifying the code to do what you want it to do, then try writing your own applications. Details of how to obtain programmers and programming tools is given at the end. But be very very wary. PIC programming is one of the most addictive things ever invented! Once you start writing code, all thoughts of food, drink, bed, exercise stop until the job works. Been there, done that! Universal PIC Development Platform The module is a platform designed to run PIC software to control and interface to external hardware. An

18 pin socket is provided for a DIL packaged PIC 16F628 or 16F819 device these are two mid-range workhorse devices with most of the peripherals we will need. They can be either programmed externally , or via the In-Circuit Programming (ICP) interface. The board includes provision for either a four or two line by 16 character Liquid Crystal Display with holes on the board designed for direct installation of either of these. A suitable low cost 4x16 LCD module is available from [2]. The holes can be a convenient way to mount the whole assembly in an enclosure. Alternative LCDs or compatible displays of different dimensions can be used with a flexible jumper connection. A rotary quadrature encoder with integral push button can be fitted to the right of the LCD for applications that require up/down tuning or entry of variable parameters in conjunction with the display. An alternative would be an off-board encoder with separate pushbutton and it is also possible to use a stepper motor with a differential line-receiver interface as described in Design Notes [3] User Input / Output The whole purpose of the module is to provide a capability for controlling or reading external hardware. For this, up to five Input/Output lines are made available on an 8-pin header, along with +5V and ground connections. Depending on the choice of PIC, these connections can function as analogue inputs as well as digital I/O. Two more digital only I/O lines as well as the processor reset line are accessible using the 4 way in circuit programming header, making a total of up to seven connections for the most demanding or projects. A LED mounted on the PCB just above the rotary encoder can be allocated to one of these lines. Example of devices that can be controlled are : Serially programmed Synthesizer chips requiring three, or sometimes just two, connections. Serial D/A converters for generating voltage levels defined by software, like PSUs, test equipment, audio generators External high resolution A/D converters more than the 10 bits offered by the integral A/D Serially programmed expansion chips, like relay drivers for controlling high current external

hardware. Or just shift registers like that used for the LCD.

Introduction to Peripheral Interface Controllers (PIC)


Peripheral Interface Controllers (PIC) is one of the advanced microcontrollers developed by microchip technologies. These microcontrollers are widely used in modern electronics applications. A PIC controller integrates all type of advanced interfacing ports and memory modules. These controllers are more advanced than normal microcontroller like INTEL 8051. The first PIC chip was announced in 1975 (PIC1650). As like normal microcontroller, the PIC chip also combines a microprocessor unit called CPU and is integrated with various types of memory modules (RAM, ROM, EEPROM ,etc), I/O ports, timers/counters, communication ports, etc.

PIC Chip Image From All PIC microcontroller family uses Harvard architecture. This architecture has the program and data accessed from separate memories so the device has a program memory bus and a data memory bus (more than 8 lines in a normal bus). This improves the bandwidth (data throughput) over traditional von Neumann architecture where program and data are fetched from the same memory (accesses over the same bus). Separating program and data memory further allows instructions to be sized differently than the 8-bit wide data word. Basic structure of a modern Peripheral interface controller chip is show in the picture below.

PIC Structure Source of the image


CPU

The function of CPU in PIC is same as a normal microcontroller CPU. A PIC CPU consists of several sub units such as instruction decoder, ALU, accumulator, control unit, etc. The CPU in PIC normally supports Reduced Instruction Set Computer (RISC) architecture (Reduced Instruction Set Computer (RISC), a type of microprocessor that focuses on rapid and efficient processing of a relatively small set of instructions. RISC design is based on the premise that most of the instructions a computer decodes and executes are simple. As a result, RISC architecture limits the number of instructions that are built into the microcontroller but optimizes each so it can be carried out very rapidly (usually within a single clock cycle.) . These RISC structure gives

the following advantages. The RISC structure only has 35 simple instructions as compared to others The execution time is same for most of the instructions (except very few numbers). The execution time required is very less (5 million instructions/second (approximately).
Memory

The memory in a PIC chip used to store the data and programs temporary or permanently. As like normal microcontrollers, the PIC chip also has certain amount of RAM, ROM, EEPROM, other flash memory, etc. ROM memory is used for permanent storage. The ROM memory also called as n program memory. A PI chip has certain amount of ROM memory. EEPROM memory is another category of ROM memory. The contents in the EEPROM changes during run time and at that time it acts like a RAM memory. But the difference is after the power goes off , the data remains in this ROM chip. This is the one of the special advantages of EEPROM. In the PIC chip the function of EPROM is to store the values created during the runtime. RAM memory is the one of the complex memory module in a PIC chip. This memory associated with various type of registers (special function registers and general purpose registers) and memory BANK modules (BANK 0, BANK 1, etc.). Once the power goes off, the contents in the RAM will be cleared. As like normal microcontrollers, the RAM memory is used to store temporary data and provide immediate results.
Flash memory

This is a special type of memory where READ, WRITE, and ERASE operations can be done many times. This type of memory was invented by INTEL corporation in 1980. A PIC Chip normally contains a certain amount of flash memory.
Registers

Information is stored in a CPU memory location called a register. Registers can be thought of as the CPUs tiny scratchpad, temporarily storing instructions or data. Registers basically classified into the following. 1) General Purpose Register (GPR) A general purpose register (or processor register) is a small storage area available on a CPU whose contents can be accessed more quickly than other storage that available on PIC. A general purpose register can store both data addresses simultaneously. 2) Special Function registers (SFR) These are also a part of RAM memory locations. As compared to GPR, their purpose is predetermined during the manufacturing time and cannot be changed by the user. It is only for special dedicated functions.

Interrupts

Interrupt is the temporary delay in a running program. These delays stop the current execution for a particular interval. This interval/delay is usually called as interrupt. When an interrupt request arrives into a current execution program, then it stops its regular execution. Interrupt can be performed by externally (hardware interrupt) or internally (by using software).
Bus

BUS is the communication or data transmission/reception path in a microcontroller unit. In a normal microcontroller chip, two types of buses are normally available. 1) Data bus Data bus is used for memory addressing. The function of data bus is interfacing all the circuitry components inside the PIC chip. 2) Address bus Address bus mostly used for memory addressing. The function of address bus is to transmit the address from the CPU to memory locations.
USART or UART

These ports are used for the transmission (TX) and reception (RX) of data. These transmissions possible with help of various digital data transceiver modules like RF, IR, Bluetooth, etc. This is the one of the simplest way to communicate the PIC chip with other devices.
Oscillators

Oscillator unit basically an oscillation/clock generating circuit which is used for providing proper clock pulses to the PIC chip. This clock pulses also helps the timing and counting applications . A PIC chip normally use various types of clock generators. According to the application and the type of PIC used, the oscillators and its frequencies may vary. RC (Resistor-Capacitor), LC (Inductor-Capacitor), RLC (Resistor-Inductor-capacitor), crystal oscillators, etc are the normal oscillators used with A PIC chip.
STACK

The entire PIC chip has an area for storing the return addresses. This area or unit called Stack is used in some Peripheral interface controllers. The hardware stack is not accessible by software. But for most of the controllers, it can be easily accessible.
Input/output ports

These ports are used for the interfacing various input/output devices and memories. According to the type of PIC, the number of ports may change.

Advanced functioning blocks

These sections include various advanced features of a PIC chip. According to the type of PIC, these features may change. Various advanced features in a peripheral interface controller are power up timer, oscillator start up timer, power on reset, watch dog timer, brown out reset, in circuit debugger, low voltage programming, voltage comparator, CCP modules etc.
Limitations of PIC Architecture

Peripheral Interface Controller Small Register banking switch required to Operations and registers Program memory is not accessible.
Advantages of PIC Controlled System

has only one accumulator. instruction set. access RAM of other devices. are not orthogonal.

Reliability The PIC controlled system often resides machines that are expected to run continuously for many years without any error and in some cases recover by themselves if an error occurs(with help of supporting firmware). Performance Many of the PIC based embedded system use a simple pipelined RISC processor for computation and most of them provide on-chip SRAM for data storage to improve the performance. Power consumption A PIC controlled system operates with minimal power consumption without sacrificing performance. Power consumption can be reduced by independently and dynamically controlling multiple power platforms. Memory Most of the PIC based systems are memory expandable and will help in easily adding more and more memory according to the usage and type of application. In small applications the inbuilt memory can be used.

Core architecture
The PIC architecture is characterized by its multiple attributes:

Separate code and data spaces (Harvard architecture).

A small number of fixed length instructions Most instructions are single cycle execution (2 clock cycles, or 4 clock cycles in 8-bit models), with one delay cycle on branches and skips One accumulator (W0), the use of which (as source operand) is implied (i.e. is not encoded in the opcode) All RAM locations function as registers as both source and/or destination of math and other functions.[6] A hardware stack for storing return addresses A fairly small amount of addressable data space (typically 256 bytes), extended through banking Data space mapped CPU, port, and peripheral registers The program counter is also mapped into the data space and writable (this is used to implement indirect jumps).

There is no distinction between memory space and register space because the RAM serves the job of both memory and registers, and the RAM is usually just referred to as the register file or simply as the registers.
Performance

The architectural decisions are directed at the maximization of speed-to-cost ratio. The PIC architecture was among the first scalar CPU designs,[citation needed] and is still among the simplest and cheapest. The Harvard architecturein which instructions and data come from separate sourcessimplifies timing and microcircuit design greatly, and this benefits clock speed, price, and power consumption. The PIC instruction set is suited to implementation of fast lookup tables in the program space. Such lookups take one instruction and two instruction cycles. Many functions can be modeled in this way. Optimization is facilitated by the relatively large program space of the PIC (e.g. 4096 14-bit words on the 16F690) and by the design of the instruction set, which allows for embedded constants. For example, a branch instruction's target may be indexed by W, and execute a "RETLW" which does as it is named - return with literal in W. Interrupt latency is constant at three instruction cycles. External interrupts have to be synchronized with the four clock instruction cycle, otherwise there can be a one instruction cycle jitter. Internal interrupts are already synchronized. The constant interrupt latency allows PICs to achieve interrupt driven low jitter timing sequences. An example of this is a video sync pulse generator. This is no longer true in the newest PIC models, because they have a synchronous interrupt latency of three or four cycles.
Advantages

The PIC architectures have these advantages:


Small instruction set to learn RISC architecture

Built in oscillator with selectable speeds Easy entry level, in circuit programming plus in circuit debugging PICKit units available for less than $50 Inexpensive microcontrollers Wide range of interfaces including IC, SPI, USB, USART, A/D, programmable comparators, PWM, LIN, CAN, PSP, and Ethernet[8]

[edit] Limitations

The PIC architectures have these limitations:


One accumulator Register-bank switching is required to access the entire RAM of many devices Operations and registers are not orthogonal; some instructions can address RAM and/or immediate constants, while others can only use the accumulator

The following stack limitations have been addressed in the PIC18 series, but still apply to earlier cores:

The hardware call stack is not addressable, so preemptive task switching cannot be implemented Software-implemented stacks are not efficient, so it is difficult to generate reentrant code and support local variables

With paged program memory, there are two page sizes to worry about: one for CALL and GOTO and another for computed GOTO (typically used for table lookups). For example, on PIC16, CALL and GOTO have 11 bits of addressing, so the page size is 2048 instruction words. For computed GOTOs, where you add to PCL, the page size is 256 instruction words. In both cases, the upper address bits are provided by the PCLATH register. This register must be changed every time control transfers between pages. PCLATH must also be preserved by any interrupt handler.[9]

Which PIC to Use


How do you find a PIC that is right for you out of nearly 2000 different models of PIC microcontrollers? The Microchip website has an excellent Product Selector Tool. You simply enter your minimum requirements and optionally desired requirements, and the resulting part numbers are displayed with the basic features listed. You can buy your PIC processors directly from Microchip Direct, Microchip's online store. Pricing is the same or sometimes better than many distributors. Rule Number 1: only pick a microprocessor you can actually obtain. PICs are all similar, and therefore you don't need to be too picky about which model to use.

If there is only 1 kind of PIC available in your school storeroom, use it. If you order from a company such as Newark or DigiKey , ignore any part that is "out of stock" -- only order parts PIC 18x

The PIC 18x series are available in a 28 and 40-pin DIP package. They have more ports, more ADC, etc... PIC 18s are generally considered to be very high-end microcontrollers, and are even sometimes called full-fledged CPUs. Microchip is currently (as of 2007) producing 6 Flash microcontrollers with a USB interface. All are in the PIC18Fx family. (The 28 pin PIC18F2450, PIC18F2455, PIC18F2550; and the 40/44 pin PIC18F4450, PIC18F4455, PIC18F4550 ). that are "in stock". This will save you lots of time in creating your project

Das könnte Ihnen auch gefallen