6 Months Synopsis With PIC Microprocessor

Embed Size (px)

Citation preview

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    1/36

    1

    GURU NANAK DEV UNIVERSITY (REGIONAL CAMPUS)

    SYNOPSIS REPORT

    ON

    EMBEDDED SYSTEM

    Submitted in the partial fulfillment of the requirement for the award of degree of

    Bachelors of Technology

    In

    Submitted to

    Mr. SHASHI RANA

    Name of the Student: Hiteshwar Dutt

    Name of the Training Guide:

    Dapinder Lalotra

    University Roll Number: 2010ECA1721

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    2/36

    2

    INFOWIZ is an ISO 9001:2008 certified company. It has been working from more

    than 5 years in the field of IT and Web Development and has been providing its

    clients with its exceptional quality and Web Design, Development and SEO

    service.Infowizs clients ranges from individuals to professionals and small, medium

    and large scaled Businesses. In 2008, Info wiz entered into IT outsourcing and

    partnered successfully with many offshore Web and SEO companies of

    US,UK,France,Ireland,Canada and

    Australia etc to provide them quality and timely services. INFOWIZ does not boost

    itself of being the best Development Company but automatically enjoys reputable

    position among top Web Development companies because Info wiz timely deliver and

    quality work. Employees of Info wiz dont claim for something they cant deliver.

    Before taking a project from a client, employee asks Info wiz for all their needs and

    requirements. After that skilled of employee and team of professionals analyze the

    need and come up with a plan as how they can work to completely satisfy those

    requirements of our clients. Then they work step by step keeping their client informed

    about the progress and complete the project in time giving complete contentment to

    them .From concept building to implementation of any project, their team manages

    projects efficiently up to its completion. Their tactful strategy and dedication toward

    quality work has given us to the recognition they enjoy and that is why their clients

    only come back to them whenever they require any kind of web related solutions.

    They do not only emphasize on formulating an attractive solution to their clients, but

    they believe in providing a workable solution. INFOWIZ offers research based Search

    Engine Marketing product that help to achieve greater insights to your online

    business. Their Research & Development arm offers SEO tools for SEM

    professionals.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    3/36

    3

    ACKNOWLEDGEMENT

    Success is a sweet fruit, which everyone want to strives to taste. To achieve this goal,

    one has to put in physical and mental efforts. Each time I write this report, gain strong

    appreciation for the following fact: I could not do it without the help of many talented

    and dedicated people. So I wish to express my appreciation for those whose help has

    been most valuable.

    Firstly, I would like to express our gratitude and appreciation to Mr.Harjit Singh

    (head of company), who explained us everything about training process as the

    company and made us familiar with the company staff. We are equally grateful to Er.

    Sunil kumar (instructor),who shorted out many of our problems regarding the training

    and gave us the proper material to work with.

    We are also grateful to(training and placement officer)for arranging the

    six week training for us and providing us with all necessary information about the

    same.

    Finally I would like to say thanks to all the people of the company for their kind

    operation.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    4/36

    4

    ABSTRACT

    The usual reason for embedding a computer is to interact with the

    environment, often by monitoring and controlling external machinery. Many

    embedded systems have substantially

    different design constraints than desktop computing applications. No single

    characterization applies to the diverse spectrum of embedded systems. Some

    combination of cost pressure, long life-cycle, real-time requirements, reliability

    requirements, and design culture dysfunction can make it difficult to be successful

    applying traditional computer design methodologies and tools to embedded

    applications there is currently little tool support for expanding embedded computer

    design to the scope of holistic embedded system design. Knowing the strengths and

    weaknesses of current approaches can set expectations appropriately, identify risk

    areas to tool adopters, and suggest ways in which tool builders can meet industrial

    needs?

    Many embedded systems have requirements that differ significantly

    both in details and in scope from desktop computers. The demands of the specific

    application and the interface with external equipment may dominate the system

    design. Long life-cycles and in some cases extreme cost sensitivity require more

    attention to optimization based on these goals rather than maximizing the

    computational throughput.

    Recent interest in hardware/software co design is a step in the right

    direction, as it permits tradeoffs between hardware and software that are critical for

    more cost-effective embedded systems.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    5/36

    5

    Introduction:-

    We are living in the Embedded World. You are surrounded with many embedded

    products and your daily life largely depends on the proper functioning of these gadgets.

    Television, Radio, CD player of your living room, Washing Machine or Microwave

    Oven in your kitchen, Card readers, Access Controllers, Palm devices of your work space

    enable you to do many of your tasks very effectively. Apart from all these, many

    controllers embedded in your car take care of car operations between the bumpers and

    most of the times you tend to ignore all these controllers.

    Theoretically, an embedded controller is a combination of a piece of microprocessor

    based hardware and the suitable software to undertake a specific task.

    These days designers have many choices in microprocessors/ microcontrollers.

    Especially, in 8 bit and 32 bit, the available variety really may overwhelm even an

    experienced designer. Selecting a right microprocessor may turn out as a most difficult

    first step and it is getting complicated as new devices continue to pop-up very often.

    In the 8 bit segment, the most popular and used architecture is Intel's 8031. Market

    acceptance of this particular family has driven many semiconductor manufacturers to

    develop something new based on this particular architecture. Even after 25 years of

    existence, semiconductor manufacturers still come out with some kind of device using

    this 8031 core.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    6/36

    6

    EMBEDDED SYSTEM

    Embedded system employs a combination of software & hardware to perform a

    specific function. It is a part of a larger system which may not be a computer Works

    in a reactive & time constrained environment.

    Any electronic system that uses a CPU chip, but that is not a general-purpose

    workstation, desktop or laptop computer is known as embedded system. Such systems

    generally use microprocessors; microcontroller or they may use custom-designed

    chips or both. They are used in automobiles, planes, trains, space vehicles, machine

    tools, cameras, consumer and office appliances, cell phones, PDAs and other

    handhelds as well as robots and toys. The uses are endless, and billions of

    microprocessors are shipped every year for a myriad of applications. In embedded

    systems, the software is permanently set into a read-only memory such as a ROM or

    flash memory chip, in contrast to a general-purpose computer that loads its programs

    into RAM each time.

    A specialized computer system that is part of a larger system or machine typically, an

    embedded system is housed on a single microprocessor board with the programs

    stored in ROM. Virtually all appliances that have a digital Interface -- watches,

    microwaves, VCRs, cars -- utilize embedded systems. Some embedded systems

    include an operating system, but many are so specialized that the entire logic can be

    implemented as a single program. Embedded systems programming is the

    development of programs intended to be part of a larger operating system or, in a

    somewhat different usage, to be incorporated on a microprocessor that can then be

    included as part of a variety of hardware devices. Several other definitions are:

    A combination of computer hardware and software, and perhaps additional

    mechanical or other parts, designed to perform a dedicated function. In some cases,

    embedded systems

    Are part of a larger system or product, as in the case of an antilock braking system in

    a car. Contrast with general-purpose computer.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    7/36

    7

    A specialized computer system which is dedicated to a specific task. Embedded

    systems range in size from a single processing board to systems with operating

    systems (ex, Linux, Windows NT Embedded). Examples of embedded systems are

    medical equipment and manufacturing equipment.

    A computer system that is a component of a larger machine or system. Embedded

    systems can respond to events in real time. Most digital appliances, such as watches

    or cars, utilize an embedded system.

    Hardware and software that forms a component of some larger system and is

    expected to function without human intervention. Typically an embedded system

    consists of a single board microcomputer with software in ROM, which starts running

    a dedicated application as soon as power is turned on and does not stop until power is

    turned off.

    An embedded system is some combination of computer hardware and software,

    either fixed in capability or programmable, that is specifically designed for a

    particular kind of application device. Industrial machines, automobiles, medical

    equipment, cameras, household appliances, airplanes, vending machines, and toys (as

    well as the more obvious cellular phone and PDA) are among the myriad possible

    hosts of an embedded system.

    A phrase that refers to a device that contains computer logic on a chip inside it.

    Such equipment is electrical or battery powered. The chip controls one or more

    functions of the equipment, such as remembering how long it has been since the

    device last received maintenance,

    An embedded system is a special purpose computer system, which is completely

    encapsulated by the device it controls. An embedded system has specific requirements

    and performs pre-defined tasks, unlike a general-purpose personal computer.

    5 An embedded system is a special-purpose computer system, which is completely

    encapsulated by the device it controls. An embedded system has specific requirements

    and performs pre-defined tasks, unlike a general-purpose personal computer.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    8/36

    8

    o

    EMBEDDED SYSTEM APPLICATIONS:-

    Consumer electronics, e.g., cameras, cell phones etc

    Consumer products, e.g. washers, microwave ovens etc.

    Automobiles (anti-lock braking, engine control etc.)

    Industrial process controller &defence applications.

    Computer/Comm. products, e.g. printers, FAX machines etc.

    Medical Equipments.

    ATMs

    Aircrafts

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    9/36

    9

    o TYPES OF MICROCONTROLLER ARCHITECTURE:

    There are two types of Microcontroller architecture designed for embedded system

    development. These are:

    1) RISC- Reduced instruction set computer

    2)

    CISC- Complex instruction set computer

    DIFFERENCE BETWEEN CISC AND RISC:

    CISC stands for Complex Instruction Set Computer. Most PC's use CPU based

    on this architecture. For instance Intel and AMD CPU's are based on CISC

    architectures. Typically CISC chips have a large amount of different and

    complex instructions. In common CISC chips are relatively slow (compared to

    RISC chips) per instruction, but use little (less than RISC) instructions. MCS-

    51 family microcontrollers based on CISC architecture.

    RICS stands for Reduced Instruction Set Computer. The philosophy behind it

    is that almost no one uses complex assembly language instructions as used by

    CISC, and people mostly use compilers which never use complex instructions.

    Therefore fewer, simpler and faster instructions would be better, than the

    large, complex and slower CISC instructions. However, more instructions are

    needed to accomplish a task. Atmels AVR microcontroller based on RISC

    architecture.

    COMPUTER DESIGN REQUIREMENTS

    Embedded computers typically have tight constraints on both functionality and

    implementation. In particular, they must guarantee real time operation reactive to

    external events, conform to size and weight limits, budget power and cooling

    consumption, satisfy safety and reliability requirements, and meet tight cost targets.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    10/36

    10

    Real time/reactive operation

    Real time system operation means that the correctness of a

    computation depends, in part, on the time at which it is delivered. The Signal

    Processing and Mission Critical example systems have a significant requirement for

    real time operation in order to meet external I/O and control stability requirements.

    Reactive computation means that the software executes in response to external

    events. These events may be periodic, in which case scheduling of events to

    guarantee performance may be possible. On the other hand, many events may be a

    periodic, in which case the maximum event arrival rate must be estimated in order to

    accommodate worst case situations. Most embedded systems have a significant

    reactive component.

    Design challenge:

    Worst case design analyses without undue pessimism in the face of hardware

    with statistical performance characteristics (e.g.,cache memory).

    Small size, low weight

    In transportation and portable systems, weight may be critical for fuel

    economy or human endurance. Among the examples, the Mission Critical system has

    much more stringent size and weight requirements than the others because of its use

    in a flight vehicle, although all examples have restrictions of this type.

    Design challenges:

    Non-rectangular, non-planar geometries.

    Packaging and integration of digital, analog, and power circuits to reduce size.

    Safe and reliable

    Some systems have obvious risks associated with failure. In mission-critical

    applications such as aircraft flight control, failure of the embedded computer.

    However, many embedded systems that could cause personal or property

    damage. This vulnerability is often resolved at the system level.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    11/36

    11

    o History of 8051

    Intel Corporation introduced an 8-bit microcontroller called 8051 in 1981 this

    controller had 128 bytes of RAM, 4k bytes of on chip ROM, two timers, one serial

    port, and four ports all are on single chip. The 8051 is an 8 bit processor, meaning that

    the CPU can work on only 8 bit data at a time. Data larger than 8 bits broken into 8 bit

    pieces to be processed by CPU. It has for I/O 8 bit wide.

    Features of the 8051:- Quantity

    1)

    ROM 4K bytes

    2)

    RAM 128 bytes

    3) Timer 2

    4)

    I/O pins 32

    5)

    Serial port 1

    6) Interrupt sources 6

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    12/36

    12

    o 8051 ARCHITECTURE OVERVIEW

    The 8051 family is one of the most common microcontroller architectures used

    worldwide. 8051 based microcontrollers are offered in hundreds of variants from

    many different silicon manufacturers 7.

    The 8051 is based on an 8-bit CISC core with Harvard architecture. It's an 8-bit CPU,

    optimized for control applications with extensive Boolean processing (single-bit logic

    capabilities), 64K program and data memory address space and various on-chip

    peripherals.

    The 8051 microcontroller family offers developers a wide variety of high-integration

    and cost-effective solutions for virtually every basic embedded control application.

    From traffic control equipment to input devices and computer networking products,

    8051 u.c deliver high performance together with a choice of configurations and

    options matched to the special needs of each application.

    Whether it's low power operation, higher frequency performance, expanded on-chip

    RAM, or an application-specific requirement, there's a version of the 8051

    microcontroller that's right for the job. When it's time to upgrade product features and

    functionality, the 8051 architecture puts you on the first step of a smooth and cost-

    effective upgrade path - to the enhanced performance of the 151 and 251

    microcontrollers.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    13/36

    13

    BLOCK DIAGRAM OF 8081:-

    Block diagram of 8051

    o PIN CONFIGURATION OF 8051

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    14/36

    14

    There are four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports.

    All the ports upon RESET are configured as output, ready to be used as output ports.

    To use any of these ports as an input port, it must be programmed.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    15/36

    15

    Port 0:- Port 0 occupies a total of 8 pins (pins 32-39) .It can be used for input

    or output. To use the pins of port 0 as both input and output ports, each pin

    must be connected externally to a 10K ohm pull-up resistor. This is due to the

    fact that P0 is an open drain, unlike P1, P2, and P3.Open drain is a term used

    for MOS chips in the same way that open collector is used for TTL chips.

    With external pull-up resistors connected upon reset, port 0 is configured as an

    output port. For example, the following code will continuously send out to

    port 0 the alternating values 55H and AAH

    Port 0 as input: - With resistors connected to port 0, in order to make it an

    input, the port must be programmed by writing 1 to all the bits. In the

    following code, port 0 is configured first as an input port by writing 1's to it,

    and then data is received from the port and sent to P1.

    Dual Role of Port 0:-Port 0 is also designated as AD0-AD7, allowing it to be

    used for both address and data. When connecting an 8051/31 to an external

    memory, port 0 provides both address and data. The 8051 multiplexes address

    and data through port 0 to save pins. ALE indicates if P0 has address or data.

    When ALE = 0, it provides data D0-D7, but when ALE =1 it has address and

    data with the help of a 74LS373 latch.

    Port 1:- Port 1 occupies a total of 8 pins (pins 1 through 8). It can be used as

    input or output. In contrast to port 0, this port does not need any pull-upresistors since it already has pull-up resistors internally. Upon reset, Port 1 is

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    16/36

    16

    configured as an output port. For example, the following code will

    continuously send out to port1 the alternating values 55h &AAh

    Port 1 as input:-To make port1 an input port, it must be programmed as such

    by writing 1 to all its bits. In the following code port1 is configured first as an

    input port by writing 1s to it, then data is received from the port and saved in

    R7 ,R6 & R5.

    Port 2 :-Port 2 occupies a total of 8 pins (pins 21- 28). It can be used as input

    or output. Just like P1, P2 does not need any pull-up resistors since it already

    has pull-up resistors internally. Upon reset, Port 2 is configured as an output

    port. For example, the following code will send out continuously to port 2 the

    alternating values 55h and AAH. That is all the bits of port 2 toggle

    continuously.

    Port 2 as input:- To make port 2 an input, it must programmed as such by

    writing 1 to all its bits. In the following code, port 2 is configured first as an

    input port by writing 1s to it. Then data is received from that port and is sent

    to P1 continuously.

    Dual role of port 2:- In systems based on the 8751, 8951, and DS5000, P2 is

    used as simple I/O. However, in 8031-based systems, port 2 must be used

    along with P0 to provide the 16-bit address for the external memory. As

    shown in pin configuration 8051, port 2 is also designed as A8-A15, indicating

    the dual function. Since an 8031 is capable of accessing 64K bytes of externalmemory, it needs a path for the 16 bits of the address. While P0 provides the

    lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of the

    address. In other words, when 8031 is connected to external memory, P2 is

    used for the upper 8 bits of the 16 bit address, and it cannot be used for I/O.

    Port 3:-port 3 occupies a total of 8 pins, pins 10 through 17. It can be used as

    input or output. P3 does not need any pull-up resistors, the same as P1 and P2

    did not. Although port 3 is configured as an output port upon reset. Port 3 has

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    17/36

    17

    the additional function of providing some extremely important signals such as

    interrupts.

    This information applies both 8051 and 8031 chips. There functions are as

    follows:-

    PORT 3 Function pin

    1) P3.0 RxD 10

    2) P3.1 TxD 11

    3) P3.2 ___

    Int0

    12

    4) P3.3 ___

    Int1

    13

    5) P3.4 T0 14

    6) P3.5 T1 15

    7) P3.6 ___

    WR

    16

    8) P3.7 ___

    RD

    17

    P3.0 and P3.1 are used for the RxD and TxD serial communications signals. Bits P3.2

    and P3.3 are set aside for external interrupts. Bits P3.4 and P3.5 are used for timers 0

    and 1. Finally P3.6 and P3.7 are used to provide the WR and RD signals of external

    memories connected in 8031 based systems.

    ALE/PROG :- Address Latch Enable is an output pulse for latching the low

    byte of the address during accesses to external memory. This pin is also the

    program pulse input (PROG) during Flash programming. In normal operation,

    ALE is emitted at a constant rate of 1/ 6 the oscillator frequency and may be

    used for external timing or clocking purposes. Note, however, that one ALE

    pulse is skipped during each access to external data memory. If desired, ALE

    operation can be disabled by setting bit 0 of SFR location 8EH. With the bit

    set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    18/36

    18

    pin is weakly pulled high. Setting the ALE-disable bit has no effect if the

    microcontroller is in external execution mode.

    PSEN :- Program Store Enable is the read strobe to external program memory.

    When the AT89S8252 is executing code from external program memory,

    PSEN is activated twice each machine cycle, except that two PSEN activations

    are skipped during each access to external data memory.

    EA/VPP:-External Access Enable. EA must be strapped to GND in order to

    enable the device to fetch code from external program memory locations

    starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is

    programmed, EA will be internally latched on reset. EA should be strapped to

    VCC for internal program executions. This pin also receives the 12-volt

    programming enable voltage (VPP) during Flash programming when 12-volt

    programming is selected.

    XTAL1:- Input to the inverting oscillator amplifier and input to the internal

    clock operating circuit.

    XTAL2 :-Output from the inverting oscillator amplifier.

    oFEATURES:-

    Compatible with MCS-51Products

    8K bytes of In-System Reprogrammable Downloadable Flash Memory

    - SPI Serial Interface for Program Downloading- Endurance: 1,000 Write/Erase Cycles

    2K bytes EEPROM

    - Endurance: 100,000 Write/Erase Cycles

    4.0V to 6V Operating Range

    Fully Static Operation: 0 Hz to 24 MHz

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    19/36

    19

    Three-Level Program Memory Lock

    256 x 8 bit Internal RAM

    32 Programmable I/O Lines

    Three 16 bit Timer/Counters

    Nine Interrupt Sources

    Programmable UART Serial Channel

    SPI Serial Interface

    Low Power Idle and Power Down Modes

    Interrupt Recovery From Power Down

    Programmable Watchdog Timer

    Dual Data Pointer

    Power Off Flag

    256 x 8 bit Internal RAM

    32 Programmable I/O Lines

    Three 16 bit Timer/Counters

    o HARDWARE INTERFACINGS AND PROGRAMMING:-

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    20/36

    20

    There are two types of programming language used for microcontroller programming:

    1) Low Level Language(Assembly Language)

    2)

    High Level Language(C Language )

    o INTERFACING OF VARIOUS DEVICES:-

    1) LED Interfacing

    C code for Blinking LEDs connected on PORT2:

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    21/36

    21

    #include

    void delay(unsigned int time);

    void main(void)

    0{

    While(1)

    {

    P2=0xff;

    delay(20);

    P2=0x55;

    }

    }

    void delay(unsigned int time)

    {

    Unsigned intI,j;

    For(i=0;i

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    22/36

    22

    The function of each of the connections is shown in the table below:-

    Pins 1 & 2 are the power supply lines, VSS & VDD. The VDD pin should be

    connected to the positive supply & VSS to the 0V supply or ground.

    Although the LCD module data sheets specify 5V D.C. supply (at only a few

    milliamps), supplies of 6V & 4.5V both work well, and even 3V is sufficient for some

    modules. Consequently, these modules can be effectively and economically powered

    by batteries.

    Pin 3 is a control pin, VEE, which is used to alter the contrast of the display.

    Ideally, these pin should be connected to a variable voltage supply. A preset

    potentiometer connected between the power supply lines, with its wiper

    connected to the contrast pin is suitable in many cases, but be aware that some

    modules may require a negative potential; as low as 7V in some cases. For

    absolute simplicity, connecting this pin to 0V will often suffice. Ideally, these

    pin should be connected to a variable voltage supply. A preset potentiometer

    connected between the power supply lines, with its wiper connected to the

    contrast pin is suitable in many cases, but be aware that some modules may

    require a negative potential; as low as in some cases. For absolute simplicity,

    connecting this pin to will often suffice.

    Ideally, these pin should be

    connected to a variable voltage supply. A preset potentiometer connected

    between the power supply lines, with its wiper connected to the contrast pin is

    suitable in many cases, but be aware that some modules may require a

    negative potential; as low as in some cases. For absolute simplicity,

    connecting this pin to 0V will often suffice. A preset potentiometer connected

    between the power supply lines, with its wiper connected to the contrast pin is

    suitable in many cases, but be aware that some modules may require anegative potential; as low as in some cases. For absolute simplicity,

    connecting this pin to 0V will often suffice

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    23/36

    23

    Pin 4 is

    register select

    (RS) line. Pin

    no.

    NAME FUNCTION

    1 Vss Ground

    2 Vdd +ve supply

    3 Vee contrast

    4 RS Register select

    5 R/W Read/Write

    6 E Enable

    7 D0 Data Bit 0

    8 D1 Data Bit 1

    9 D2 Data Bit 2

    10 D3 Data Bit 3

    11 D4 Data Bit 4

    12 D5 Data Bit 5

    13 D6 Data Bit 6

    14 D7 Data Bit 7

    Three command control inputs. When this line is low, data bytes transferred to the

    display are treated as commands, and data bytes read from the display indicate its

    status. By setting the RS line high, character data can be transferred to and from themodule.

    Pin 5 is (R/W) line. This line is pulled low in order to write commands or

    character data to the module, or pulled high to read character data or status

    information from its registers.

    Pin 6 is Enable (E) line. This input is used to initiate the actual transfer of

    commands or character data between the module and the data lines. When

    writing to the display, data is transferred only on the high to low transition of

    this signal. However, when reading from the display, data will become

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    24/36

    24

    available shortly after the low to high transition and remain available until the

    signal falls low again.

    Pins 7 to 14 are the eight data bus lines (D0 to D7). Data can be transferred to

    and from the display, either as a single 8-bit byte or as two 4-bit nibbles. In

    the latter case, only the upper four data lines (D4 to D7) are used. This $-bit

    mode is beneficial when using a microcontroller, as fewer I/O lines are

    required.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    25/36

    25

    C code for LCD display:

    #include //defining library

    //-------------------------------------------------------------------------

    voidmsdelay(unsigned int time); //defining function prototype

    voidlcd_cmd(unsigned char value);

    voidlcd_data(unsigned char value);

    //-------------------------------------------------------------------------

    sfr ldata = 0xA0; //defining constant for Port2

    sbit rs = P3^0;

    sbit rw = P3^1; //defining constant for Port3.0

    sbit en = P3^2;

    //--------------------------------------------------------------------------

    void main()

    {

    lcd_cmd(0x38); //init. LCD 2 lines, 5x7 matrix

    msdelay(50);

    lcd_cmd(0x0E); //Display On, Cursor On

    msdelay(50);

    lcd_cmd(0x01); //Clear LCD

    msdelay(50);

    lcd_cmd(0x06); //Shift Cursor Right

    msdelay(50);

    lcd_cmd(0x80); //Line 1,Position 0

    msdelay(50);lcd_data('G'); //Display Letter N

    msdelay(50);

    lcd_data('A');

    msdelay(50);

    lcd_data('U');

    msdelay(50);

    lcd_data('R');

    msdelay(50);

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    26/36

    26

    lcd_data('A');

    msdelay(50);

    lcd_data('V);

    msdelay(50);

    }

    voidlcd_cmd(unsigned char value)

    {

    ldata = value; //Put Value on Lcd Port

    rs = 0;

    rw = 0;

    en = 1; //strobe the enable pin

    msdelay(1);

    en = 0;

    }

    voidlcd_data(unsigned char value)

    {

    ldata = value; //Put Value on Lcd Port

    rs = 1;

    rw = 0;

    en = 1; //strobe the enable pin

    msdelay(1);

    en = 0;}

    voidmsdelay(unsigned int time)

    {

    inti,j;

    for(i=0;i

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    27/36

    27

    3)Serial communication between At89v51rd2 and PC:-

    a)Serial Reception(From PC to microcontroller)

    C- Code for serial reception:

    #include

    sbitrs=P3^0;

    sbitrw=P3^1;

    sbit en=P3^2;

    sfrldata=0x90;

    voidlcom(unsigned char value);

    voidldat(unsigned char value);

    void delay(unsigned int time);

    unsigned char first[]="GAURAV WADHWA";

    unsignedint i;

    unsigned char first1[]="IET BHADDAL";

    unsigned char mybyte;

    void main()

    {

    lcom(0x38);

    lcom(0x06);

    lcom(0x0e);

    lcom(0x01);

    for(i=0;i

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    28/36

    28

    delay(50);

    lcom(0x01);

    TMOD=0X20;

    TH1=0XFD;

    TCON=0X00;

    SCON=0X50;

    TR1=1;

    while(1)

    {

    while(RI==0);

    mybyte=SBUF;

    ldat(mybyte);

    }

    RI=0;

    }

    voidlcom(unsigned char value)

    {

    ldata=value;

    rs=0;

    rw=0;

    en=1;

    delay(5);

    en=0;

    }

    voidldat(unsigned char value){

    ldata=value;

    rs=1;

    rw=0;

    en=1;

    delay(5);

    en=0;

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    29/36

    29

    }

    void delay(unsigned int time)

    {

    unsignedintk,j;

    for(k=0;k

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    30/36

    30

    C code for seven segment display :

    #include //defining library

    //-------------------------------------------------------------------------

    voidmsdelay(unsigned int time); //defining function prototype

    void compare();

    sfrport_data = 0xA0; //defining constant for Port2

    int m = 0X00;

    //--------------------------------------------------------------------------

    void main()

    {

    while(1)

    {

    compare();

    port_data = m;

    msdelay(15);

    m--;

    }

    }

    void compare()

    {

    if(m == 0X0F)

    m = 0X09;

    if(m == 0X1F)m = 0X19;

    if(m == 0X2F)

    m = 0X29;

    if(m == 0X3F)

    m = 0X39;

    if(m == 0X4F)

    m = 0X49;

    if(m == 0X5F)

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    31/36

    31

    m = 0X59;

    if(m == 0X6F)

    m = 0X69;

    if(m == 0X7F)

    m = 0X79;

    if(m == 0X8F)

    m = 0X89;

    if(m == 0XFF)

    m = 0X99;

    if(m == ~0X01)

    m = 0X99;

    }

    voidmsdelay(unsigned int time)

    {

    inti,j;

    for(i=0;i

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    32/36

    32

    PIC MICROCONTROLLER

    PICis a family ofmodified Harvard architecturemicrocontrollersmade byMicrochip

    Technology,derived from the PIC1650 originally developed byGeneral Instrument's

    Microelectronics Division. The name PIC initially referred to "Peripheral Interface

    Controller".

    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.

    History

    Various older (EPROM) PIC microcontrollers

    The original PIC was built to be used with General Instrument's new 16-bitCPU,the

    CP1600.While generally a goodCPU,the CP1600 had poorI/Operformance, and the

    8-bit PIC was developed in 1975 to improve performance of the overall system by

    offloading I/O tasks from the CPU. The PIC used simplemicrocodestored in ROM to

    perform its tasks, and although the term was not used at the time, it shares some

    common features withRISCdesigns.

    http://en.wikipedia.org/wiki/Modified_Harvard_architecturehttp://en.wikipedia.org/wiki/Modified_Harvard_architecturehttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Microchip_Technologyhttp://en.wikipedia.org/wiki/Microchip_Technologyhttp://en.wikipedia.org/wiki/Microchip_Technologyhttp://en.wikipedia.org/wiki/Microchip_Technologyhttp://en.wikipedia.org/wiki/General_Instrumenthttp://en.wikipedia.org/wiki/General_Instrumenthttp://en.wikipedia.org/wiki/General_Instrumenthttp://en.wikipedia.org/wiki/Central_processing_unithttp://en.wikipedia.org/wiki/Central_processing_unithttp://en.wikipedia.org/wiki/Central_processing_unithttp://en.wikipedia.org/wiki/General_Instrument_CP1600http://en.wikipedia.org/wiki/General_Instrument_CP1600http://en.wikipedia.org/wiki/CPUhttp://en.wikipedia.org/wiki/CPUhttp://en.wikipedia.org/wiki/CPUhttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Microcodehttp://en.wikipedia.org/wiki/Microcodehttp://en.wikipedia.org/wiki/Microcodehttp://en.wikipedia.org/wiki/Reduced_instruction_set_computerhttp://en.wikipedia.org/wiki/Reduced_instruction_set_computerhttp://en.wikipedia.org/wiki/Reduced_instruction_set_computerhttp://en.wikipedia.org/wiki/File:PIC16CxxxWIN.JPGhttp://en.wikipedia.org/wiki/Reduced_instruction_set_computerhttp://en.wikipedia.org/wiki/Microcodehttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/CPUhttp://en.wikipedia.org/wiki/General_Instrument_CP1600http://en.wikipedia.org/wiki/Central_processing_unithttp://en.wikipedia.org/wiki/General_Instrumenthttp://en.wikipedia.org/wiki/Microchip_Technologyhttp://en.wikipedia.org/wiki/Microchip_Technologyhttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Modified_Harvard_architecture
  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    33/36

    33

    In 1985, General Instrument spun off their microelectronics division and the new

    ownership cancelled almost everything board peripherals (serial communication

    modules,UARTs,motor control kernels, etc.) and program memory from 256 words

    to 64k words and more (a "word" is one assembly language instruction, varying from

    12, 14 or 16bitsdepending on the specific PICmicrofamily).

    PIC and PICmicro are registered trademarks of Microchip Technology. It is generally

    thought that PIC stands for Peripheral Interface Controller,

    and PIC1650 devices was "Programmable Interface Controller". The acronym was

    quickly replaced with "Programmable Intelligent Computer".

    PIN DIAGRAM(18f4520)

    http://en.wikipedia.org/wiki/Microelectronicshttp://en.wikipedia.org/wiki/Microelectronicshttp://en.wikipedia.org/wiki/Serial_communicationshttp://en.wikipedia.org/wiki/Serial_communicationshttp://en.wikipedia.org/wiki/Serial_communicationshttp://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitterhttp://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitterhttp://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitterhttp://en.wikipedia.org/wiki/Bithttp://en.wikipedia.org/wiki/Bithttp://en.wikipedia.org/wiki/Bithttp://en.wikipedia.org/wiki/Micro_programming_languagehttp://en.wikipedia.org/wiki/Micro_programming_languagehttp://en.wikipedia.org/wiki/Micro_programming_languagehttp://en.wikipedia.org/wiki/Micro_programming_languagehttp://en.wikipedia.org/wiki/Bithttp://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitterhttp://en.wikipedia.org/wiki/Serial_communicationshttp://en.wikipedia.org/wiki/Microelectronics
  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    34/36

    34

    FEATURES

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    35/36

    35

    NEW CORE FEATURES

    All of the devices in the PIC18F2420/2520/4420/4520

    family incorporate a range of features that can significantly

    reduce power consumption during operation.

    Key items include:

    Alternate Run Modes: By clocking the controller

    from the Timer1 source or the internal oscillator

    block, power consumption during code execution

    can be reduced by as much as 90%.

    Multiple Idle Modes: The controller can also run

    with its CPU core disabled but the peripherals still

    active. In these states, power consumption can be

    reduced even further, to as little as 4% of normal

    operation requirements.

    On-the-Fly Mode Switching: The powermanaged

    modes are invoked by user code during

    operation, allowing the user to incorporate

    power-saving ideas into their applications

    software design.

    Low Consumption in Key Modules: The

    power requirements for both Timer1 and theWatchdog Timer are minimized.

  • 8/10/2019 6 Months Synopsis With PIC Microprocessor

    36/36

    MULTIPLE OSCILLATOR OPTIONS

    AND FEATURES

    All pin of the devices in the PIC18F2420/2520/4420/4520

    family offer ten different oscillator options, allowing

    users a wide range of choices in developing application

    hardware. These include:

    Four Crystal modes, using crystals or ceramic

    resonators

    Two External Clock modes, offering the option of

    using two pins (oscillator input and a divide-by-4

    clock output) or one pin (oscillator input, with the

    second pin reassigned as general I/O)

    Two External RC Oscillator modes with the same

    pin options as the External Clock modes

    An internal oscillator block which provides an

    8 MHz clock and an INTRC source

    (approximately 31 kHz), as well as a range of

    6 user-selectable clock frequencies, between

    125 kHz to 4 MHz, for a total of 8 clock

    frequencies.

    A Phase Lock Loop (PLL) frequency multiplier,

    available to both the High-Speed Crystal and Internal

    Oscillator modes, which allows clock speeds of

    up to 40 MHz. Used with the internal oscillator, the

    PLL gives users a complete selection of clockspeeds, from 31 kHz to 32 MHzall without using

    an external crystal or clock circuit.

    Besides its availability as a clock source, the internal

    oscillator block provides a stable reference source that

    gives the family additional features for robust

    operation: