1. You can now buy finished microcontroller project from us, Check out the Store for the complete list of projects.
  2. Need a custom project, Send us some details about your project. So that we can quote the price for it.

PREPAID ENERGY

Discussion in 'Microcontrollers' started by phani.d.g.v, Dec 19, 2007.

  1. phani.d.g.v

    phani.d.g.v New Member

    Likes Received:
    0
    Trophy Points:
    0
    HELLO BINU SIR,

    I'm unable to understand the code for storing the data in EEPROM.I don,t get the thing why we are using MOV R2,#8. and why the CALL OUTS is regularly referred.please clear my doubts:)





    STORE A BYTE IN EEPROM (Data 8F in address location 2AH)
    ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    MOV A,#WTCMD ;LOAD WRITE COMMAND
    CALL OUTS ;SEND IT
    MOV A,#2AH ;GET BYTE ADDRESS
    CALL OUT ;SEND IT
    MOV A,#8FH ;GET DATA
    CALL OUT ;SEND IT
    CALL STOP ;SEND STOP CONDITION

    ////////////////////////////////////////////////////////////////////

    OUTS: MOV R2,#8 ;LOOP COUNT -- EQUAL TO BIT COUNT
    SETB SDA1 ;INSURE DATA IS HI
    SETB SCL1 ;INSURE CLOCK IS HI
    NOP ;NOTE 1
    NOP
    NOP
    CLR SDA1 ;START CONDITION -- DATA = 0
    NOP ;NOTE 1
    NOP
    NOP
    CLR SCL1 ;CLOCK = 0

    /////////////////////////////////////////////////////////////////////


    OUT: MOV R2,#8 ;LOOP COUNT -- EQUAL TO BIT COUNT


    krishna
  2. HiteshDR

    HiteshDR New Member

    Likes Received:
    0
    Trophy Points:
    0
    OUT: MOV R2,#8 ;LOOP COUNT -- EQUAL TO BIT COUNT

    meaining of this instruction is #08d will save in R2.
    according to me, this is used to count the bits comming from SDA.

    --------------------------​
    Hitesh D R
    (i m @:: hitesh12@gmail.com)
  3. Binu

    Binu Administrator

    Likes Received:
    135
    Trophy Points:
    63
    The count 8 is for 8bits. The data's are sent through serially with respect to clock.
    The count 8 is number of clocks for transmitting 1byte (8bits)

    "CALL OUTS" is the subroutine which gives a start condition and transmit the data through the i2c bus.
  4. phani.d.g.v

    phani.d.g.v New Member

    Likes Received:
    0
    Trophy Points:
    0
    thankq sir,
    but in this code we are entering 8 to R2 and we are not using R2 at any part of the subroutine so, why to write that one??

    also the WTCMD content is placed in A then how the EEPROM(card) will detect that the MC is calling the data in card??

    and also why A is entered the value 2AH if it is not used in any part of the subroutine? after the CALL OUTS there is no return command so, where does the operation went after calling OUTS??
    please clear my doubts......

    krishna
  5. Binu

    Binu Administrator

    Likes Received:
    135
    Trophy Points:
    63
    Please post your doubts regarding my projects under the "Doubts in my project" [^]

    No the R2 is used in that subroutine

    EEPROM will not detect the micro.
    The microcontroller will check for the card for every second. if it found a card then it will read the amount from the card.

    Check the program correctly there is a ret instruction at the end of the subroutine.
  6. phani.d.g.v

    phani.d.g.v New Member

    Likes Received:
    0
    Trophy Points:
    0
    if we were using the AT24C08(card) instead of AT24C02 what are the changes to be made in the main program ??

    krishna
  7. Binu

    Binu Administrator

    Likes Received:
    135
    Trophy Points:
    63
    No need to change, since both IC's have same address
  8. phani.d.g.v

    phani.d.g.v New Member

    Likes Received:
    0
    Trophy Points:
    0
    sir,
    in the prepaid energy meter program in the MDELAY routine why we are entering the 0A6H into A and why we are incrementing A in MD_OLP routine and what will be poped up after pop ACC please help me.....

    krishna
  9. Binu

    Binu Administrator

    Likes Received:
    135
    Trophy Points:
    63
    Dont get confused, its just a delay program. you can use your own delay program for the subroutine MDELAY.
Loading...

Share This Page

Loading...