em lab m.tech

Upload: upendar-rao-kolichalam

Post on 14-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 em lab m.tech

    1/27

    INDEX

    I Cycle

    1. SERIAL COMMUNICATION............................................................2

    1(a) SERIAL COMMUNICATION (continuous display of one character)...........2

    1(b) SERIAL COMMUNICATION (display of one name)...................................4

    1(c) SERIAL COMMUNICATION (without using arrays display your name).. ...6

    2(b) Real Time Timer.....................................................................................8

    3. LOOK UP TABLE........................................................................11

    4. LCD INTERFACE TO 8051...........................................................15

    5. ADC& DAC INTERFACE TO 8051.................................................18

    5a) ADC.......................................................................................................18

    AIM: To write an 8051 embedded c code for ADC & DAC Interface to 805118

    5b) DAC....................................................................................................... 20

    6. KEYBOARD...............................................................................23

    6a) Keyboard interface to 8051..................................................................23

    6b) Interfacing to keyboard using switch case............................................26

    1

  • 7/27/2019 em lab m.tech

    2/27

    1. SERIAL COMMUNICATION

    1(a) SERIAL COMMUNICATION (continuous display of one character)

    AIM: To write an 8051embedded c code for the continuous display of oneCharacter

    HARDWARE TOOLS

    PCMicro Controller Evaluation Board

    Power Supply

    SOFTWARE TOOLS:

    IDE- Keil vision

    Programming tool: ATMEL FLIP

    THEORY:

    Serial communication is the process of sending data one bit at a time, sequentially, over a

    communication channel or computer bus. This is in contrast to Parallel communication,where several bits are sent as a whole, on a link with several parallel channels. Serial

    communication is used for all long-haul Communication and most computer networks,

    where the cost of cable and Synchronization difficulties make parallel communication

    impractical. Serial Computer buses are becoming more common even at shorterdistances, as Improved signal integrity and transmission speeds in newer serial

    technologies have begun to outweigh the parallel bus's advantage of simplicity (no need

    for serializer and deserializer, or SerDes) and to outstrip its disadvantages (clock skew,

    Interconnect density). The migration from PCI to PCI Express is an example.

    PROCEDURE:

    1) Write the code using Keil vision IDE

    2) Complete the code

    3) Connect the power supply to the evaluation board and switch on the power supply4) Connect the standard RS232 cross cable between the computers serial port and the

    board

    5) Using the programming tool Atmel flip port the program code on to the

    Microcontroller evaluation board6) Result obtained is viewed in corresponding ports

    SOURCE CODE:

    #include

    void main ()

    {TMOD=0x20;

    SCON=0x50;

    TH1=0xFD;

    2

  • 7/27/2019 em lab m.tech

    3/27

    TR1=1;

    while (1)

    {SBUF='A';

    while (TI==0);

    TI=0;}

    }

    RESULT: Hence the 8051 embedded c code for the continuous display of oneCharacter is verified

    3

  • 7/27/2019 em lab m.tech

    4/27

    1(b) SERIAL COMMUNICATION (display of one name)

    AIM: To write an 8051 embedded c code for the display of one character

    HARDWARE TOOLS

    PC

    Micro Controller Evaluation BoardPower Supply

    SOFTWARE TOOLS:

    IDE- Keil vision

    Programming tool: ATMEL FLIP

    THEORY:

    Serial communication is the process of sending data one bit at a time, sequentially, over acommunication channel or computer bus. This is in contrast to Parallel communication,

    where several bits are sent as a whole, on a link with several parallel channels. Serialcommunication is used for all long-haul Communication and most computer networks,

    where the cost of cable and Synchronization difficulties make parallel communication

    impractical. Serial Computer buses are becoming more common even at shorterdistances, as Improved signal integrity and transmission speeds in newer serial

    technologies have begun to outweigh the parallel bus's advantage of simplicity (no need

    for serializer and deserializer, or SerDes) and to outstrip its disadvantages (clock skew,Interconnect density). The migration from PCI to PCI Express is an example.

    PROCEDURE:1) Write the code using Keil vision IDE2) Complete the code

    3) Connect the power supply to the evaluation board and switch on the power supply

    4) Connect the standard RS232 cross cable between the computers serial port and theboard

    5) Using the programming tool Atmel flip port the program code on to the

    Microcontroller evaluation board6) Result obtained is viewed in corresponding ports

    SOURCE CODE:#include

    #include

    void serail_init (void);void serial_init (void)

    {

    SCON=0x20;TMOD=0x20;

    4

  • 7/27/2019 em lab m.tech

    5/27

    TH1=0xFD;

    TR1=1;

    TI=1;}

    void main (void)

    {

    serial_init ();

    while (1){printf ("Hello! World\n");

    }

    }

    RESULT: Hence the 8051 embedded c code for the display of one nameis verified

    5

  • 7/27/2019 em lab m.tech

    6/27

    1(c) SERIAL COMMUNICATION (without using arrays

    display your name)

    AIM: To write an8051 embedded c code for the without using arrays display your name

    HARDWARE TOOLS

    PC

    Micro Controller Evaluation Board

    Power Supply

    SOFTWARE TOOLS:

    IDE- Keil vision

    Programming tool: ATMEL FLIP

    THEORY:

    Serial communication is the process of sending data one bit at a time, sequentially, over acommunication channel or computer bus. This is in contrast to Parallel communication,

    where several bits are sent as a whole, on a link with several parallel channels. Serial

    communication is used for all long-haul Communication and most computer networks,where the cost of cable and Synchronization difficulties make parallel communication

    impractical. Serial Computer buses are becoming more common even at shorter

    distances, as Improved signal integrity and transmission speeds in newer serial

    technologies have begun to outweigh the parallel bus's advantage of simplicity (no needfor serializer and deserializer, or SerDes) and to outstrip its disadvantages (clock skew,

    Interconnect density). The migration from PCI to PCI Express is an example.

    PROCEDURE:

    1) Write the code using Keil vision IDE

    2) Complete the code3) Connect the power supply to the evaluation board and switch on the power supply

    4) Connect the standard RS232 cross cable between the computers serial port and the

    board

    5) Using the programming tool Atmel flip port the program code on to theMicrocontroller evaluation board

    6) Result obtained is viewed in corresponding ports

    SOURCE CODE:

    #includevoid SerTx (unsigned char);

    void main (void)

    {TMOD=0X20;

    6

  • 7/27/2019 em lab m.tech

    7/27

    TH1=0XFD;

    SCON=0X50;

    TR1=1;while (1)

    {

    SerTx ('C');SerTx ('M');

    SerTx ('R');

    SerTx ('E');SerTx ('C');

    }

    }

    void SerTx (unsigned char x){

    SBUF=x;

    while (TI==0);

    TI=0;}

    RESULT: Hence the 8051 embedded c code for the without using arrays display yourname is verified

    2.TIMERS

    7

  • 7/27/2019 em lab m.tech

    8/27

    2. TIMER

    2(b) Real Time Timer

    AIM: To study and verify Real time timer

    HARDWARE TOOLS

    PC Micro Controller Evaluation Board

    Power Supply

    SOFTWARE TOOLS:

    IDE- Keil vision

    Programming tool: ATMEL FLIP

    THEORY:Timer is a clock that controls the sequence of an event while counting in fixed intervals

    of time. A Timer is used for producing precise time delay. Secondly, it can be used torepeat or initiate an action after/at a known period of time. This feature is very commonly

    used in several applications. An example could be setting up an alarm which triggers at a

    point of time or after a period of time.

    Most of the microcontrollers have inbuilt Timers. Timers in a controller not only generate

    time delays but they can also be used as counters. They are used to count an action orevent. The value of counter increases by one, every time its corresponding action or event

    occurs. Timers in a controller are inbuilt chips that are controlled by special function

    registers (SFRs) assigned for Timer operations. These SFRs are used to configure Timersin different modes of operations.While working with microcontrollers, it is more than often required to generate time

    delays. There are two possible ways of generating time delays. First is by using the code,

    like using for or while loops in a C program. However, the delays provided by thesoftware are not very precise. The other method is to use Timers. Timers provide timedelays that are very precise and accurate.

    Microcontroller has two Timers designated as Timer0 and Timer1. Each of these timers isassigned a 16-bit register. The value of a Timer register increases by one every time a

    timer counts. Timer takes a time period of one machine cycle to count one. This means

    that the maximum number of times a timer can count without repeating is 216, i.e.,

    65536. So the maximum allowed counts in value of Timer registers can be from 0000H toFFFFH. Since 8051 is an 8 bit controller, the registers of 8051 Timers are accessed as

    two different registers; one for lower byte and other for higher byte. For example, register

    of Timer0 is accessed as TL0 for lower byte and TH0 for higher byte. Similarly TL1 and

    TH1 are registers assigned to Timer 1.

    While using 8051 Timers certain factors need to be considered, like whether the Timer is

    to be used for time keeping or for counting; whether the source for time generation is

    8

    http://www.engineersgarage.com/microcontrollerhttp://www.engineersgarage.com/microcontroller
  • 7/27/2019 em lab m.tech

    9/27

    external clock or the controller itself; how many bits of Timer register are to be used or

    left unused.

    The registers of Timers are loaded with some initial value. The value of a Timer registerincreases by one after every machine cycle. One machine cycle duration is the 1/12th of

    the frequency of the crystal attached to the controller.

    A register called TMOD is used for configuring the Timers for the desired operation.

    TMOD is an 8-bit register with following bit configuration:

    The lower four bits (TMOD.0 TMOD.3) are used to configure Timer 0 while the higherfour bits (TMOD.4 TMOD.7) are for Timer 1. When GATE is high, the corresponding

    Timer is enabled only when there is an interrupt at corresponding INTx pin of AT89C51

    controller and Timer control bit is high. Otherwise only setting Timer control bit is

    sufficient to start the Timer.

    PROCEDURE:

    1) Write the code using Keil vision IDE

    2) Complete the code

    3) Connect the power supply to the evaluation board and switch on the power supply4) Connect the standard RS232 cross cable between the computers serial port and the

    board5) Using the programming tool Atmel flip port the program code on to the

    microcontroller evaluation board

    6) Result obtained is viewed in corresponding ports

    SOURCE CODE:

    Timer interrupts

    #include

    #includesbit pin=P1^5;

    void timer1_int ();

    void main (){

    AUXR=0x10;

    EA=1;timer1_int ();

    While (1);

    }

    Void timer1_int (){

    TMOD=0x10;

    TH1=0x4B;TL1=0xFE;

    TR1=1;

    ET1=1;}

    timer1_isr () interrupt 3

    {

    9

  • 7/27/2019 em lab m.tech

    10/27

    pin=~pin;

    TF1=0;

    TH1=0x4B;TL1=0xFE;

    }

    Timer 0 Interrupt

    #include#include

    sbit pin=P1^5;

    void timer0_int ();

    void main (){

    timer0_int ();

    EA=1;

    while (1);}

    void timer0_int (){

    TMOD=0x02;

    TH0=0x4B;

    TL0=0xFE;TR0=1;

    ET0=1;

    }timer0_isr () interrupt 1

    {

    pin=~pin;TF0=0;

    TH0=0x4B;

    TL0=0Xff;}

    10

  • 7/27/2019 em lab m.tech

    11/27

    3. LOOK UP TABLE

    AIM: To write an 8051 embedded c code for the look up table

    HARDWARE TOOLS

    PCMicro Controller Evaluation Board

    Power Supply

    SOFTWARE TOOLS:

    IDE- Keil vision Programming tool: ATMEL FLIP

    THEORY:

    A lookup table is a data structure, usually an array or associative array, often used toreplace a runtime computation with a simpler array indexing operation. The savings in

    terms of processing time can be significant, since retrieving a value from memory is oftenfaster than undergoing an 'expensive' computation or input/output operation. The tables

    may be pre calculated and stored in static program storage or calculated (or "perfected")

    as part of a programs initialization phase (memorization). Lookup tables are also usedextensively to validate input values by matching against a list of valid (or invalid) items

    in an array and, in some programming languages, may include pointer functions (or

    Offsets to labels) to process the matching input

    PROCEDURE:

    1) Write the code using Keil vision IDE2) Complete the code3) Connect the power supply to the evaluation board and switch on the power supply

    4) Connect the standard RS232 cross cable between the computers serial port and the

    board5) Using the programming tool Atmel flip port the program code on to the

    microcontroller evaluation board

    6) Result obtained is viewed in corresponding ports.

    SOURCE CODE:

    #include

    #include#include

    void start (void);

    unsigned char ReadNVROM (void);void Stop (void);

    #define ACK 1

    #define NO_ACK 0#define SLAVE 0xa0

    11

  • 7/27/2019 em lab m.tech

    12/27

    #define WRITE 0x00

    #define READ 0x01

    void DelayUs (int us);unsigned char i;

    void DelayMs (unsigned int count);

    sbit SDA=P1^0;sbit SCL=P1^1;

    write NVROM (NVROM_ARR);

    void InitSerial (void);unsigned char NVROM_ARR, temp1, temp2;

    void main ()

    {

    char AUXR;AUXR=0x10;

    NVROM_ARR=0x00;

    while (1)

    {Write NVROM (NVROM_ARR);

    NVROM_ARR+=1;DelayMs (5);

    temp1=ReadNVROM ();

    temp2=temp1;

    temp2 &=0xf0;temp2>>=4;if(temp2

  • 7/27/2019 em lab m.tech

    13/27

    DelayUs (1);

    SDA=0;

    DelayUs (1);SCL=0;

    DelayUs (1);

    }void Stop (void)

    {

    SDA=0;DelayUs (1);

    SCL=1;

    DelayUs (1);

    SDA=1;}

    void WriteI2C (unsigned char Data)

    {

    for (i=0; i

  • 7/27/2019 em lab m.tech

    14/27

    return Data;

    }

    unsigned char ReadNVROM (void){

    unsigned char buff;

    void Start ();WriteI2C (0xa0);

    WriteI2C (0x00);

    Start ();WriteI2C (0xa1);

    buff=ReadI2C (ACK);

    Stop();

    return (buff);}

    void WriteNVROM (unsigned char buff)

    {

    Start();WriteI2C (0xa0);

    WriteI2C (0x00);WriteI2C (buff);

    Stop ();

    }

    void InitSerial(void){

    SCON=0x52;

    TMOD=0x20;TH1=0xFD;

    TR1=1;

    }void DelayMs (unsigned int count)

    {

    unsigned int i;while (count)

    {

    i=115;

    while (i>0)i--;count --;

    }

    }void DelayUs (int us)

    {

    int i;for (i=0; i

  • 7/27/2019 em lab m.tech

    15/27

    4. LCD INTERFACE TO 8051

    AIM: To write an 8051 embedded c code for LCD display

    HARDWARE TOOLS:

    PCMicro Controller Evaluation Board

    Power Supply

    SOFTWARE TOOLS:

    IDE- Keil vision

    Programming tool: ATMEL FLIP

    THEORY:A liquid crystal display (LCD) is a flat panel display, electronic visual display, video

    display that uses the light modulating properties of liquid crystals (LCs). LCs do not emitlight directly. They are used in a wide range of applications, including computer

    monitors, television, instrument panels, aircraft cockpit displays, signage, etc. They are

    common in consumer devices such as video players, gaming devices, clocks, watches,calculators, and telephones. LCDs have displaced cathode ray tube (CRT) displays in

    most applications. They are usually more compact, lightweight, portable, less expensive,

    more reliable, and easier on the eyes. They are available in a wider range of screen sizes

    than CRT and plasma displays, and since they do not use phosphors, they cannot sufferimage burning.

    LCDs are more energy efficient and offer safer disposal than CRTs. Its low electricalpower consumption enables it to be used in battery-powered electronic equipment. It is anelectronically modulated optical device made up of any number of segments filled with

    liquid crystals and arrayed in front of a light source (backlight) or reflector to produce

    images in color or monochrome. The most flexible ones use an array of small pixels.

    PROCEDURE:

    1) Write the code using Keil vision IDE

    2) Complete the code3) Connect the power supply to the evaluation board and switch on the power

    supply

    4) Connect the standard RS232 cross cable between the computers serial portand the board

    5) Using the programming tool Atmel flip port the program code on to the

    Microcontroller evaluation board6) Result obtained is viewed in corresponding ports

    SOURCE CODE:

    #include

    15

  • 7/27/2019 em lab m.tech

    16/27

    #include

    sbit rs = P2^7;

    sbit en = P2^5;sbit rw = P2^6;

    sbit b = P0^7;

    void writecmd (unsigned char a);void writedat (unsigned char b);

    void busy ();

    void writestr (unsigned char *s);void writecmd (unsigned char a)

    {

    busy ();

    rs = 0;rw = 0;

    P0 = a;

    en = 1;

    en = 0;}

    void writedat (unsigned char b){

    busy ();

    rs = 1;

    rw = 0;P0 = b;

    en = 1;

    en = 0;}

    void busy ()

    {en = 0;

    P0 = 0xFF;

    rs = 0;rw = 1;

    while (b==1)

    {

    en=0;en=1;

    }

    en=0;}

    void writestr (unsigned char *s)

    {unsigned char l, i;

    l = strlen(s);

    for (i=1; i

  • 7/27/2019 em lab m.tech

    17/27

    Writedat (*s);

    s++;

    }}

    main ()

    {P0=0x00;

    P2=0x00;

    writecmd (0x3C);writecmd (0x0E);

    writecmd (0x01);

    writestr ("Wel-Come to LCD");

    writecmd (0xC4);writestr ("Program");

    while (1);

    }

    RESULT: Hence the embedded c code for LCD display is verified

    17

  • 7/27/2019 em lab m.tech

    18/27

    5. ADC& DAC INTERFACE TO 8051

    5a) ADC

    AIM: To write an 8051 embedded c code for ADC & DAC Interface to 8051

    HARDWARE TOOLS

    PCMicro Controller Evaluation Board

    Power Supply

    SOFTWARE TOOLS:

    IDE- Keil vision

    Programming tool: ATMEL FLIP

    THEORY:An analog-to-digital converter (abbreviated ADC, A/D or A to D) is a device that

    converts a continuous quantity to a discrete time digital representation. An ADC may alsoprovide an isolated measurement. Typically, an ADC is an electronic device that converts

    an input analog voltage or current to a digital number proportional to the magnitude of

    the voltage or current. However, some non-electronic or only partially electronic devices,such as rotary encoders, can also be considered ADCs. The digital output may use

    different coding schemes.

    Typically the digital output will be a two's complement binary number that is

    proportional to the input, but there are other possibilities. An encoder, for example, mightoutput a Gray code.

    PROCEDURE:1) Write the code using Keil vision IDE2) Complete the code

    3) Connect the power supply to the evaluation board and switch on the power supply

    4) Connect the standard RS232 cross cable between the computers serial port and theboard

    5) Using the programming tool Atmel flip port the program code on to the

    microcontroller evaluation board6) Result obtained is viewed in corresponding ports

    SOURCE CODE:

    #include

    #include sbit wr = P3^0;

    sbit rd = P3^1;

    sbit d1 = P2^7;sbit d2 = P2^6 ;

    unsigned char data d;

    unsigned int a=0, b=0, c=0;void int1 (void) interrupt 1

    18

  • 7/27/2019 em lab m.tech

    19/27

    {

    EA=0;

    rd = 0;d=P1;

    rd=1;

    a = (d & 0x0F);b = d >> 4;

    EA=1;

    }void tmr1 (void) interrupt 3

    {

    c++;

    TH1=0xEC;TL1=0x77;

    TF1=0;

    If ((c%2)==0)

    {d1=1;

    d2=0;P0=b;

    } else

    {

    d1=0;d2=1;

    P0=a;

    }}

    main ()

    {P0=0x00;

    P1=0xFF;

    TMOD=0x90;TH1=0xEC;

    TL1=0x77;

    TR1=1;

    d1=0;d2=1;

    P0=a;

    IE=0x89;wr = 0;

    wr = 1;

    while (1);}

    RESULT: Hence the embedded c code for ADC is verified

    19

  • 7/27/2019 em lab m.tech

    20/27

    5b) DAC

    AIM: To write an 8051 embedded c code for DAC

    HARDWARE TOOLSPC

    Micro Controller Evaluation Board

    Power Supply

    SOFTWARE TOOLS:

    IDE- Keil visionProgramming tool: ATMEL FLIP

    THEORY:

    A DAC converts an abstract finite-precision number (usually a fixed-point binary

    number) into a physical quantity (e.g., a voltage or a pressure). In particular, DACs areoften used to convert finite-precision time series data to a continually varying physical

    signal. A typical DAC converts the abstract numbers into a concrete sequence ofimpulses that are then processed by a reconstruction filter using some form of

    interpolation to fill in data between the impulses. Other DAC methods (e.g., methods

    based on Delta-sigma modulation) produce a pulse-density modulated signal that canthen be filtered in a similar way to produce a smoothly varying signal. As per the

    NyquistShannon sampling theorem, a DAC can reconstruct the original signal from the

    sampled data provided that its bandwidth meets certain requirements (e.g., a basebandsignal with bandwidth less than the Nyquist frequency). Digital sampling introduces

    quantization error that manifests as low-level noise added to the reconstructed signal.

    PROCEDURE:

    1) Write the code using Keil vision IDE

    2) Complete the code

    3) Connect the power supply to the evaluation board and switch on the power supply4) Connect the standard RS232 cross cable between the computers serial port and the

    board

    5) Using the programming tool Atmel flip port the program code on to theMicrocontroller evaluation board

    6) Result obtained is viewed in corresponding ports

    SOURCE CODE:#include

    void delay1 ();

    void delay2 ();void sqrarwave ();

    void triwave ();

    void stairwave ();void delay1 ()

    20

  • 7/27/2019 em lab m.tech

    21/27

    {

    int a, b;

    for (a=0; a

  • 7/27/2019 em lab m.tech

    22/27

    Delay2 ();

    }

    }void main ()

    {

    P2=0x00;P3=0xFF;

    while (P3=0xFF);

    switch (P3){

    case 0xFE:

    delay1 ();

    P3=0xFF;squarwave ();

    break;

    case 0xFD:

    delay1 ();P3=0xFF;

    triwave ();break;

    case 0xFB:

    delay1 ();

    P3=0xFF;stairwave ();

    break;

    }}

    RESULT: Hence the embedded c code for the DAC is verified.

    22

  • 7/27/2019 em lab m.tech

    23/27

    6. KEYBOARD

    6a) Keyboard interface to 8051

    AIM: To write an 8051 embedded c code for the keyboard

    HARDWARE TOOLS

    PCMicro Controller Evaluation Board

    Power Supply

    SOFTWARE TOOLS:

    IDE- Keil vision

    Programming tool: ATMEL FLIP

    THEORY:

    In computing, a keyboard is a typewriter-style keyboard, which uses an arrangement of

    buttons or keys, to act as mechanical levers or electronic switches.Following the decline of punch cards and paper tape, interaction via tele printer style

    keyboards became the main input device for computers, despite the development of

    alternative input devices, such as the mouse, touch screen, pen devices, character

    recognition and voice recognition, the keyboard remains the most commonly used andmost versatile device used for direct (human) input into computers.

    A keyboard typically has characters engraved or printed on the keys and each press of a

    key typically corresponds to a single written symbol. However, to produce some symbols

    requires pressing and holding several keys simultaneously or in sequence. While mostkeyboard keys produce letters, numbers or signs (characters), other keys or simultaneous

    key presses can produce actions or computer commands.

    PROCEDURE:

    1) Write the code using Keil vision IDE2) Complete the code

    3) Connect the power supply to the evaluation board and switch on the power supply

    4) Connect the standard RS232 cross cable between the computers serial port and the

    board5) Using the programming tool Atmel flip port the program code on to the

    microcontroller evaluation board6) Result obtained is viewed in corresponding ports

    SOURCE CODE:

    #include #define KEYPAD P1

    #define display P3

    void delay (int k)

    23

  • 7/27/2019 em lab m.tech

    24/27

    {

    int i;

    TR0=0;for(i=0; i

  • 7/27/2019 em lab m.tech

    25/27

    colloc=KEYPAD & 0xF0;

    if (colloc !=0xF0)

    {rowloc=1;

    goto next;

    }KEYPAD=0xFB;

    colloc=KEYPAD & 0xF0;

    if (colloc !=0xF0){

    rowloc=2;

    goto next;

    }KEYPAD=0xF7;

    colloc=KEYPAD & 0xF0;

    rowloc=3;

    goto next;next:

    if (colloc==0xE0)display= (keypad [rowloc][0]);

    else if (colloc==0xD0)

    display= (keypad[rowloc][1]);

    else if (colloc==0xB0)display = (keypad [rowloc][2]);

    }

    }void DelayMs (unsigned int count)

    {

    unsigned int i;while count) {

    i = 115;

    while (i>0) i--;count--;

    }

    }

    RESULT: Hence the embedded c code for the keyboard is verified.

    25

  • 7/27/2019 em lab m.tech

    26/27

    6b) Interfacing to keyboard using switch case

    AIM: To write an 8051 embedded c code for keyboard using Switch Case

    HARDWARE TOOLS

    PC

    Micro Controller Evaluation Board

    SOFTWARE TOOLS:

    IDE- Keil visionProgramming tool: ATMEL FLIP

    THEORY:

    In computing, a keyboard is a typewriter-style keyboard, which uses an arrangement of

    buttons or keys, to act as mechanical levers or electronic switches. Following the declineof punch cards and paper tape, interaction via teleprinterstyle keyboards became the main

    input device for computers.Despite the development of alternative input devices, such as the mouse, touch screen,

    pen devices, character recognition and voice recognition, the keyboard remains the most

    commonly used and most versatile device used for direct (human) input into computers.A keyboard typically has characters engraved or printed on the keys and each press of a

    key typically corresponds to a single written symbol. However, to produce some symbols

    requires pressing and holding several keys simultaneously or in sequence. While mostkeyboard keys produce letters, numbers or signs (characters), other keys or simultaneous

    key presses can produce actions or computer commands.

    PROCEDURE:

    1) Write the code using Keil vision IDE

    2) Complete the code

    3) Connect the power supply to the evaluation board and switch on the power supply4) Connect the standard RS232 cross cable between the computers serial port and the

    board

    5) Using the programming tool Atmel flip port the program code on to themicrocontroller evaluation board

    6) Result obtained is viewed in corresponding ports

    SOURCE CODE:#include

    #include

    char code column [] = {0xbf, 0xdf,0xef};void keypad (void) interrupt 2

    {

    char x, key;unsigned int k;

    26

  • 7/27/2019 em lab m.tech

    27/27

    EX1 = 0;

    P1=0xff;

    for (x=0; x