introduction to micro controller

Upload: harish-shenoy

Post on 06-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Introduction to Micro Controller

    1/36

  • 8/2/2019 Introduction to Micro Controller

    2/36

    2

    While this drama was going on, hobbyists and professionals, also split in two groups and

    protected by anonymity, were working hard on their projects. Then, someone suddenly put a

    question: Why should not we make a universal component? A cheap, universal integrated

    circuit that could be programmed and used in any field of electronics, device or wherever

    needed? Technology has been developed enough as well as the market. Why not? So it

    happened, body and spirit were united and the first integrated circuit was designed and called

    the MICROCONTROLLER

    1.1 What are microcontrollers and what are they used for?

    Like all good things, this powerful component is basically very simple. It is made by mixing

    tested and high- quality "ingredients" (components) as per following receipt:

    1. The simplest computer processor is used as the "brain" of the future system.2. Depending on the taste of the manufacturer, a bit of memory, a few A/D converters,

    timers, input/output lines etc. are added

    3. All that is placed in some of the standard packages.4. A simple software able to control it all and which everyone can easily learn about has

    been developed.

    On the basis of these rules, numerous types of microcontrollers were designed and they quickly

    became man's invisible companion. Their incredible simplicity and flexibility conquered us a

    long time ago and if you try to invent something about them, you should know that you are

    probably late, someone before you has either done it or at least has tried to do it.

    The following things have had a crucial influence on development and success of the

    microcontrollers:

    Powerful and carefully chosen electronics embedded in the microcontrollers canindependetly or via input/output devices (switches, push buttons, sensors, LCD

  • 8/2/2019 Introduction to Micro Controller

    3/36

    3

    displays, relays etc.), control various processes and devices such as industrial

    automation, electric current, temperature, engine performance etc.

    Very low prices enable them to be embedded in such devices in which, until recent timeit was not worthwhile to embed anything. Thanks to that, the world is overwhelmed

    today with cheap automatic devices and various smart appliances.

    Prior knowledge is hardly needed for programming. It is sufficient to have a PC(software in use is not demanding at all and is easy to learn) and a simple device

    (called the programmer) used for loading raedy-to-use programs into the

    microcontroller.

    So, if you are infected with a virus called electronics, there is nothing left for you to do but to

    learn how to use and control its power.

    How does the microcontroller operate?

    Even though there is a large number of different types of microcontrollers and even more

    programs created for their use only, all of them have many things in common. Thus, if you

    learn to handle one of them you will be able to handle them all. A typical scenario on the basis

    of which it all functions is as follows:

    1. Power supply is turned off and everything is stillthe program is loaded into themicrocontroller, nothing indicates what is about to come

    2. Power supply is turned on and everything starts to happen at high speed! The controllogic unit keeps everything under control. It disables all other circuits except quartz

    crystal to operate. While the preparations are in progress, the first milliseconds go by

    3. Power supply voltage reaches its maximum and oscillator frequency becomes stable.SFRs are being filled with bits reflecting the state of all circuits within the

    microcontroller. All pins are configured as inputs. The overall electronics starts opera

    in rhythm with pulse sequence. From now on the time is measured in micro and

    nanoseconds.

    4. Program Counter is set to zero. Instruction from that address is sent to instruction decwhich recognizes it, after which it is executed with immediate effect.

  • 8/2/2019 Introduction to Micro Controller

    4/36

    4

    5. The value of the Program Counter is incremented by 1 and the whole process isrepeated...several million times per second.

    1.2 What is what in the microcontroller?

    As you can see, all the operations within the microcontroller are performed at high speed and

    quite simply, but the microcontroller itself would not be so useful if there are not special

    circuits which make it complete. In continuation, we are going to call your attention to them.

    Read Only Memory (ROM)

    Read Only Memory (ROM) is a type of memory used to permanently save the program being

    executed. The size of the program that can be written depends on the size of this memory.

    ROM can be built in the microcontroller or added as an external chip, which depends on the

    type of the microcontroller. Both options have some disadvantages. If ROM is added as an

  • 8/2/2019 Introduction to Micro Controller

    5/36

    5

    external chip, the microcontroller is cheaper and the program can be considerably longer. At

    the same time, a number of available pins is reduced as the microcontroller uses its own

    input/output ports for connection to the chip. The internal ROM is usually smaller and more

    expensive, but leaves more pins available for connecting to peripheral environment. The size of

    ROM ranges from 512B to 64KB.

    Random Access Memory (RAM)

    Random Access Memory (RAM) is a type of memory used for temporary storing data and

    intermediate results created and used during the operation of the microcontrollers. The content

    of this memory is cleared once the power supply is off. For example, if the program performes

    an addition, it is necessary to have a register standing for what in everyday life is called the

    sum . For that purpose, one of the registers in RAM is called the "sum" and used for storing

    results of addition. The size of RAM goes up to a few KBs.

    Electrically Erasable Programmable ROM (EEPROM)

    The EEPROM is a special type of memory not contained in all microcontrollers. Its contents

    may be changed during program execution (similar to RAM ), but remains permanently saved

    even after the loss of power (similar to ROM). It is often used to store values, created and used

    during operation (such as calibration values, codes, values to count up to etc.), which must be

    saved after turning the power supply off. A disadvantage of this memory is that the process of

    programming is relatively slow. It is measured in milliseconds.

  • 8/2/2019 Introduction to Micro Controller

    6/36

    6

    Central Processor Unit (CPU)

    As its name suggests, this is a unit which monitors and controls all processes within the

    microcontroller and the user cannot affect its work. It consists of several smaller subunits, of

    which the most important are:

    Instruction decoder is a part of the electronics which recognizes program instructionsand runs other circuits on the basis of that. The abilities of this circuit are expressed inthe "instruction set" which is different for each microcontroller family.

    Arithmetical Logical Unit (ALU) performs all mathematical and logical operationsupon data.

  • 8/2/2019 Introduction to Micro Controller

    7/36

    7

    Accumulator is an SFR closely related to the operation of ALU. It is a kind of workingdesk used for storing all data upon which some operations should be executed

    (addition, shift etc.). It also stores the results ready for use in further processing. One of

    the SFRs, called the Status Register, is closely related to the accumulator, showing at

    any given time the "status" of a number stored in the accumulator (the number is

    greater or less than zero etc.).

    A bit is just a word invented to confuse novices at electronics. Joking aside, this wordin practice indicates whether the voltage is present on a conductor or not. If it is

    present, the approprite pin is set to logic one (1), i.e. the bits value is 1. Otherwise, if

    the voltage is 0 V, the appropriate pin is cleared (0), i.e. the bits value is 0. It is more

    complicated in theory where a bit is referred to as a binary digit, but even in this case,

    its value can be either 0 or 1.

    Input/output ports (I/O Ports)

    In order to make the microcontroller useful, it is necessary to connect it to peripheral devices.

    Each microcontroller has one or more registers (called a port) connected to the microcontroller

    pins.

  • 8/2/2019 Introduction to Micro Controller

    8/36

    8

    Oscillator

    Even pulses generated by the oscillator enable harmonic and synchronous operation of all

    circuits within the microcontroller. It is usually configured as to use quartz-crystal or ceramics

    resonator for frequency stabilization. It can also operate without elements for frequency

    stabilization (like RC oscillator). It is important to say that program instructions are not

    executed at the rate imposed by the oscillator itself, but several times slower. It happens

    because each instruction is executed in several steps. For some microcontrollers, the same

    number of cycles is needed to execute any instruction, while it's different for othermicrocontrollers. Accordingly, if the system uses quartz crystal with a frequency of 20MHz,

    the execution time of an instruction is not expected 50nS, but 200, 400 or even 800 nS,

    depending on the type of the microcontroller!

    Power Supply Circuit

    There are two things worth attention concerning the microcontroller power supply circuit:

    Brown out is a potentially dangerous state which occurs at the moment the microcontroller is

    being turned off or when power supply voltage drops to the lowest level due to electric noise.

    As the microcontroller consists of several circuits which have different operating voltage

    levels, this can cause its out of control performance. In order to prevent it, the microcontroller

    usually has a circuit for brown out reset built-in. This circuit immediately resets the whole

    electronics when the voltage level drops below the lower limit.

    Reset pin is usually referred to as Master Clear Reset (MCLR

    ) and serves for external reset ofthe microcontroller by applying logic zero (0) or one (1) depending on the type of the

    microcontroller. In case the brown out is not built in the microcontroller, a simple external

    circuit for brown out reset can be connected to this pin.

  • 8/2/2019 Introduction to Micro Controller

    9/36

    9

  • 8/2/2019 Introduction to Micro Controller

    10/36

    10

    2.Explanation of Block Diagram:

    As u can see in the diagram, the circuit consist Microcontroller, Timer Circuit, Relay,

    EEPROM, 7 Segment Display and bell.

    Microcontroller:The microcontroller is used for the synchronization of the whole circuit. The keypad is

    attached to the microcontroller, the data input in saved on the EEPROM memory. The

    controller also converts the clock time in the 7 segment display.

    Timer Circuit:The timer circuit used a crystal, to keep track of the time.

    EEPROM:The EEPROM is used to save the time, when the time stored in the memory is equal

    time in the timer circuit the relay in switched on.

    7 Segment Display:The 7 Segment display is used to display the time from the timer circuit.

    Bell:When the time stored in memory and the timer circuit matches, the relay is switched on,

    which the starts the bell.

  • 8/2/2019 Introduction to Micro Controller

    11/36

    11

    Block Diagram:

  • 8/2/2019 Introduction to Micro Controller

    12/36

    12

    3.The CircuitryThe Project takes over the task of ringing of the bell in colleges or in automatically so labour

    work is reduced. The manual switching of the bell is replaced by a inbuilt real time clock

    (DS1307) which track over the real time. The clock also has a 3V battery so if there is a power

    failure the clock will not loose track of time. The four 7-segments displays the time on the

    clock. There is a numeric keypad which is connected to the microcontroller which will take the

    input of setting the timer at what particular time the bell should ring. When the inputted time

    equals to the time on the clock present, then the Relay for the Bell is switched on.

    The Bell Ringing time can be edited at any time, so that it can be used at normal class timings

    as well as exam times. The Microcontroller AT89S8252 is used to control all the Functions, it

    get the time through the keypad and store it in its Memory.

    Clock Circuit DS1307:The PIC16F88 has a built in oscillator for a 32 kHz watch crystal a DS1307 is easier to

    use on a bread board. This is because you can control the layout of the circuit more

    easily. The RTC also makes the software easier as it takes care of all calendar functions;

    accounting for leap years etc. The DS1307 (RTC) Real Time Clock IC is an 8 pin

    device using an I2C interface.

    EEPROM:

  • 8/2/2019 Introduction to Micro Controller

    13/36

    13

    EEPROM stands for Electrically Erasable Programmable Read-Only Memory and is a

    type of non-volatile memory used in computers and other electronic devices to store

    small amounts of data that must be saved when power is removed, e.g., calibration

    tables or device configuration.

    Microcontroller AT89S8252:o 8K Bytes of In-System Reprogrammable Downloadable Flash Memoryo 2K Bytes EEPROM, Fully Static Operation: 0 Hz to 24 MHzo 4V to 6V Operating Rangeo Three-level Program Memory Locko 256 x 8-bit Internal RAM, 32 Programmable I/O Lineso Three 16-bit Timer/Counterso Nine Interrupt Sourceso Programmable UART Serial Channel, SPI Serial Interfaceo Low-power Idle and Power-down Modeso Interrupt Recovery from Power-downo Programmable Watchdog Timer, Dual Data Pointer, Power-off Flag

  • 8/2/2019 Introduction to Micro Controller

    14/36

    14

    3.1. Table 4: Component List :-Part Value Quantity

    Resistor 330E 510k 4

    2.2k 5

    56k 1

    Capacitor 33pF 2

    1uF 1

    1uF Radial 1

    Diode 1N5711 1

    Transistor BC547 4

    Keypad 1

    7 Segment Display 4

    Crystal 12Mhz 1

    32.768Khz 1

    Battery 3V 1

    Bell 1

  • 8/2/2019 Introduction to Micro Controller

    15/36

    15

    Circuit Diagram:

  • 8/2/2019 Introduction to Micro Controller

    16/36

    16

    4.Code

    INCLUDE reg_51.pdf

    RB0 EQU 000H ; Select Register Bank 0

    RB1 EQU 008H ; Select Register Bank 1 ...poke to PSW to use

    ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    ; PORT DECLERATION

    ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    SDA EQU P1.1 ;SDA=PIN5

    SCL EQU P1.0 ;SCL=PIN6

    DS1307W EQU 0D0H ; SLAVE ADDRESS 1101 000 + 0 TO WRITE

    DS1307R EQU 0D1H ; SLAVE ADDRESS 1101 000 + 1 TO READ

    KEYS EQU P3

    ROW1 EQU P3.1

  • 8/2/2019 Introduction to Micro Controller

    17/36

    17

    ROW2 EQU P3.2

    ROW3 EQU P3.3

    ROW4 EQU P3.4

    COL1 EQU P3.5

    COL2 EQU P3.6

    COL3 EQU P3.7

    DIS_A EQU P0.2

    DIS_B EQU P0.3

    DIS_C EQU P0.4

    DIS_D EQU P0.6

    DIS_E EQU P0.5

    DIS_F EQU P0.1

    DIS_G EQU P0.0

    DIS1 EQU P0.7

    DIS2 EQU P2.7

    DIS3 EQU P2.6

    DIS4 EQU P2.5

    RELAY EQU P2.4

  • 8/2/2019 Introduction to Micro Controller

    18/36

    18

    WMCON DATA 96h ; watchdog and memory control register

    EEMEN EQU 00001000b ; EEPROM access enable bit

    EEMWE EQU 00010000b ; EEPROM write enable bit

    WDTRST EQU 00000010b ; EEPROM RDY/BSY bit

    DPS EQU 00000100b ; data pointer select bit

    ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    DSEG ; This is internal data memory

    ORG 20H ; Bit adressable memory

    FLAGS DATA 20H

    LASTREAD BIT FLAGS.0

    SQW BIT FLAGS.4

    ACK BIT FLAGS.5

    BUS_FLT BIT FLAGS.6

    _2W_BUSY BIT FLAGS.7

    CANCEL BIT FLAGS.1

    CANCEL1 BIT FLAGS.2

    ALARM BIT FLAGS.3

    BITCNT DATA 21H

    BYTECNT DATA 22H

  • 8/2/2019 Introduction to Micro Controller

    19/36

    19

    SECS DATA 24H ; ' SECONDS STORAGE RAM

    MINS DATA 25H ; ' MINUTES ' '

    HRS DATA 26H ; ' HOURS ' '

    DAY DATA 27H ; ' DAY ' '

    DATE1 DATA 28H ; ' DATE ' '

    MONTH DATA 29H ; ' MONTH ' '

    YEAR DATA 2AH ; ' YEAR ' '

    CONTROL DATA 2BH ; FOR STORAGE OF CONTROL REGISTER WHEN READ.

    ALM_HOUR DATA 2CH ; INTERNAL (ALARM HOURS) STORAGE.

    ALM_MIN DATA 2DH ; INTERNAL (ALARM MINUTES) STORAGE.

    ALM_CNTRL DATA 2EH ; INTERNAL STORAGE FOR ALARM (ON) TIME.

    COUNT DATA 2FH

    SPEED DATA 30H

    VALUE_1 DATA 31H

    VALUE_2 DATA 32H

    VALUE_3 DATA 33H

    VALUE_4 DATA 34H

    NUMBER1 DATA 35H ;temp to store dialled number

    KBELL DATA 36H

    NUMB1 DATA 37H ;Temp Reg to store pressed Keys

  • 8/2/2019 Introduction to Micro Controller

    20/36

    20

    NUMB2 DATA 38H ;Temp Reg to store pressed Keys

    NUMB3 DATA 39H ;Temp Reg to store pressed Keys

    NUMB4 DATA 3AH ;Temp Reg to store pressed Keys

    KEY DATA 3BH

    TIM DATA 3CH

    STACK DATA 3FH

    ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    ; ***MACRO'S***

    SCL_HIGH MACRO

    SETB SCL ; SET SCL HIGH

    JNB SCL,$ ; LOOP UNTIL STRONG 1 ON SCL

    ENDM

    ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    CSEG AT 0 ; RESET VECTOR

    ;---------==========----------==========---------=========---------

    ; PROCESSOR INTERRUPT AND RESET VECTORS

  • 8/2/2019 Introduction to Micro Controller

    21/36

    21

    ;---------==========----------==========---------=========---------

    ORG 00H ; Reset

    JMP MAIN

    ORG 000BH ;Timer Interrupt0

    JMP REFRESH

    ORG 001BH ;Timer Interrupt1

    JMP RELAY_TIMER

    ;---------==========----------==========---------=========---------

    ; Main routine. Program execution starts here.

    ;---------==========----------==========---------=========---------

    MAIN:

    MOV PSW,#RB0 ; Select register bank 0

    MOV SP,STACK

    CLR RELAY ;Switch OFF relay

    MOV SPEED,#00H

    MOV COUNT,#00H

  • 8/2/2019 Introduction to Micro Controller

    22/36

    22

    MOV KBELL,#00H

    CLR ALARM

    MOV VALUE_1,#15H

    MOV VALUE_2,#15H

    MOV VALUE_3,#15H

    MOV VALUE_4,#15H

    CLR DIS1

    CLR DIS2

    CLR DIS3

    CLR DIS4

    MOV TMOD,#01H ;enable timer0 for scanning

    MOV TL0,#00H

    MOV TH0,#0FDH

    SETB ET0

    SETB EA

    SETB TR0 ;Start the Timer

    ; **********************************************************

    ; INITILIZE RTC

    ; **********************************************************

    SETB SDA ; ENSURE SDA HIGH

  • 8/2/2019 Introduction to Micro Controller

    23/36

    23

    SCL_HIGH ; ENSURE SCL HIGH

    CLR ACK ; CLEAR STATUS FLAGS

    CLR BUS_FLT

    CLR _2W_BUSY

    CLR SQW

    CALL OSC_CONTROL ;Initilize the RTC

    ACALL SQW_CONTROL_1HZ

    ; **********************************************************

    ; CHECK FOR ENTER THE TIME

    ; **********************************************************

    LCALL SEND_START ; SEND 2WIRE START CONDITION

    MOV A,#DS1307W ; SEND DS1307 WRITE COMMAND

    LCALL SEND_BYTE

    MOV A,#08H ; SET POINTER TO REG 08H ON DS1307

    LCALL SEND_BYTE

    LCALL SEND_STOP ; SEND STOP CONDITION

    LCALL SEND_START ; SEND START CONDITION

    MOV A,#DS1307R ; SEND DS1307 READ COMMAND

    LCALL SEND_BYTE

    LCALL READ_BYTE ; READ A BYTE OF DATA

    MOV R1,A

  • 8/2/2019 Introduction to Micro Controller

    24/36

    24

    LCALL SEND_STOP ; SEND 2WIRE STOP CONDITION

    MOV NUMBER1,#01H

    CJNE A,#0AAH,KEYBOARD1

    AJMP START_PROGRAM

    ;**********************************************************

    ; KEYBOARD ROUTINE

    ;**********************************************************

    KEYBOARD1:

    MOV KBELL,#0FFH

    KEYBOARD:

    MOV KEY,#00H

    SETB COL1

    SETB COL2

    SETB COL3

    K11: CLR ROW1

    CLR ROW2

    CLR ROW3

    CLR ROW4

    MOV A,KEYS

  • 8/2/2019 Introduction to Micro Controller

    25/36

    25

    ANL A,#11100000B

    CJNE A,#11100000B,K11 ;check till all keys released

    K2: ACALL DEALAY ;call 20 msec delay

    MOV A,KEYS ;see if any key is pressed

    ANL A,#11100000B ;mask unused bits

    CJNE A,#11100000B,OVER ;key pressed, await closure

    SJMP K2

    OVER: ACALL DEALAY

    MOV A,KEYS

    ANL A,#11100000B

    CJNE A,#11100000B,OVER1

    SJMP K2

    OVER1: MOV A,KEYS

    ORL A,#11111110B

    MOV KEYS,A

    CLR ROW1

    MOV A,KEYS

    ANL A,#11100000B

    CJNE A,#11100000B,ROW_1

    MOV A,KEYS

    ORL A,#11111110B

  • 8/2/2019 Introduction to Micro Controller

    26/36

  • 8/2/2019 Introduction to Micro Controller

    27/36

    27

    JC MAT1

    MOV KEY,#01H

    AJMP K1

    MAT1: RLC A

    JC MAT2

    MOV KEY,#02H

    AJMP K1

    MAT2: RLC A

    JC K1

    MOV KEY,#03H

    AJMP K1

    ROW_2: RLC A

    JC MAT3

    MOV KEY,#04H

    AJMP K1

    MAT3: RLC A

    JC MAT4

    MOV KEY,#05H

    AJMP K1

    MAT4: RLC A

  • 8/2/2019 Introduction to Micro Controller

    28/36

    28

    JC K1

    MOV KEY,#06H

    AJMP K1

    ROW_3: RLC A

    JC MAT5

    MOV KEY,#07H

    AJMP K1

    MAT5: RLC A

    JC MAT6

    MOV KEY,#08H

    AJMP K1

    MAT6: RLC A

    JC K1

    MOV KEY,#09H

    AJMP K1

    ROW_4: RLC A

    JC MAT7

    MOV KEY,#10H ;for *

    AJMP K1

  • 8/2/2019 Introduction to Micro Controller

    29/36

    29

    MAT7: RLC A

    JC MAT8

    MOV KEY,#00H ;for 0

    AJMP K1

    MAT8: RLC A

    JC K1

    MOV KEY,#12H ;for =

    K1:

    MOV A,KBELL

    CJNE A,#0FFH,KB_RET1

    MOV A,KEY

    CJNE A,#10H,CXCX0 ;Key to Erase last dislled NUMBER1

    MOV KEY,#00H

    MOV NUMBER1,#01H

    MOV VALUE_1,#15H

    MOV VALUE_2,#15H

    MOV VALUE_3,#15H

    MOV VALUE_4,#15H

    AJMP KEYBOARD

  • 8/2/2019 Introduction to Micro Controller

    30/36

    30

    KB_RET1: JMP KB_RET

    CXCX0: MOV A,NUMBER1

    CJNE A,#01H,CXCX1

    MOV A,KEY

    CLR C

    SUBB A,#03H ; Chk Key Pressed 0,1

    JNC CXCX5

    MOV A,KEY

    INC NUMBER1

    MOV NUMB1,KEY

    MOV VALUE_1,KEY

    AJMP KEYBOARD

    CXCX1: CJNE A,#02H,CXCX2

    MOV A,NUMB1

    CJNE A,#02,JKJL

    MOV A,KEY

    CLR C

    SUBB A,#04H ; Chk Key Pressed 0,1,2,3

    JNC CXCX5

    JKJL: MOV A,KEY

  • 8/2/2019 Introduction to Micro Controller

    31/36

    31

    CLR C

    SUBB A,#10H ; Chk Key Pressed 0,1...8,9

    JNC CXCX5

    INC NUMBER1

    MOV NUMB2,KEY

    MOV VALUE_2,KEY

    AJMP KEYBOARD

    CXCX2: CJNE A,#03H,CXCX3

    MOV A,KEY

    CLR C

    SUBB A,#06H ; Chk Key Pressed 0,1...,5

    JNC CXCX5

    INC NUMBER1

    MOV NUMB3,KEY

    MOV VALUE_3,KEY

    AJMP KEYBOARD

    CXCX3: CJNE A,#04H,CXCX4

    MOV A,KEY

    CLR C

    SUBB A,#10H ; Chk Key Pressed 0,1,....,8,9

    JNC CXCX5

  • 8/2/2019 Introduction to Micro Controller

    32/36

    32

    INC NUMBER1

    MOV NUMB4,KEY

    MOV VALUE_4,KEY

    CXCX5: AJMP KEYBOARD

    CXCX4: CJNE A,#05H,CXCX5

    MOV A,KEY

    CJNE A,#12H,CXCX5 ;Key to OK TIME

    CALL FLASHING

    MOV KBELL,#00H

    MOV A,NUMB1

    SWAP A

    ORL A,NUMB2

    MOV NUMB2,A

    MOV A,NUMB3

    SWAP A

    ORL A,NUMB4

    MOV NUMB4,A

  • 8/2/2019 Introduction to Micro Controller

    33/36

    33

    ;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((

    ; STORE THE TIME TO RTC CHIP

    ;(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((

    LCALL SEND_START ; SEND 2WIRE START CONDITION

    MOV A,#DS1307W ; LOAD DS1307 WRITE COMMAND

    LCALL SEND_BYTE ; SEND WRITE COMMAND

    MOV A,#08H ; SET DS1307 DATA POINTER TO

    BEGINNING

    LCALL SEND_BYTE ; OF USER RAM 08H

    MOV A,#0AAH ; WRITE BYTE TO ENTIRE RAM SPACE

    LCALL SEND_BYTE

    LCALL SEND_STOP ; SEND 2WIRE STOP CONTION

    LCALL SEND_START ; SEND 2WIRE START CONDITION

    MOV A,#DS1307W ; LOAD DS1307 WRITE COMMAND

    LCALL SEND_BYTE ; SEND WRITE COMMAND

    MOV A,#01H ; SET DS1307 DATA POINTER TO

    BEGINNING

    MOV VALUE_2,NUMB2

  • 8/2/2019 Introduction to Micro Controller

    34/36

    34

    MOV VALUE_3,NUMB3

    MOV VALUE_4,NUMB4

    ;**********************************************************

    DELAY:

    MOV R1,#0CCH

    REP2: MOV R2,#0FFH

    REP1: NOP

    DJNZ R2,REP1

    DJNZ R1,REP2

    RET

    END

    5.Conclusion

  • 8/2/2019 Introduction to Micro Controller

    35/36

    35

    By this project, automatic bell we have studied that integrated circuits are of

    immense use. It a microcontroller cam modified as per specifications.Thus, along with the advantages and disadvantages, etc

    6.BIBLIOGRAPHY

  • 8/2/2019 Introduction to Micro Controller

    36/36

    [1] 8051 Projectshttp://www.8051projects.info

    [2] http://www.projectsof8051.com

    [3] http://www.google.com

    http://www.8051projects.info/http://www.8051projects.info/http://www.8051projects.info/http://www.projectsof8051.com/http://www.projectsof8051.com/http://www.google.com/http://www.google.com/http://www.google.com/http://www.projectsof8051.com/http://www.8051projects.info/