EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Read, Write EEPROM problem on AT89S8253

Read, Write EEPROM problem on AT89S8253

|

Microcontroller › 8051 › Read, Write EEPROM problem on AT89S8253

  • This topic has 1 reply, 2 voices, and was last updated 10 years, 9 months ago by Ashutosh Bhatt.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • July 29, 2014 at 4:16 am #3855
    Nexus
    Participant

     

    My project is meant to  enable the User to toggle "LIKE" or "DISLIKE" and save their preferance in the EEPROM. 
     
    The data to represent "LIKE" is 0101 0101B.
    The data to represent "DISLIKE" is 1010 1010B.
    So, when the user toggles their choice, the instruction, "RR A" should rotate the values within the Accumulator and the data should be the opposite now, thus displaying the other choice.
    Firstly, the toggling isn't working. I have no idea why, this simple instruction should display the other choice, but it keeps displaying "DISLIKE".
     
    Next, I am not sure if the data need to be written/read in the EEPROM is working or right.
     
    Please do help me. Do not refer me to online materials, I have been searching online for the past few weeks. Please do provide me the solution and try to explain to me. I really keen in learning how and why it works. Thank you.
     
    ============================================
    CSEG AT 0000H
    LJMP STARTUP
     
    CSEG AT 0003H
    LJMP EXT_0
     
    CSEG AT 000BH
    LJMP TIMER_0
     
    CSEG AT 0013H
    LJMP EXT_1
     
    CSEG AT 001BH
    LJMP TIMER_1
     
    CSEG AT 0036H
    SETB P1.3 ; LEFT
    SETB P1.4 ; UP (BACK BUTTON)
    SETB P1.5 ; CENTER (LIKE/DISLIKE BUTTON)
    SETB P1.6 ; RIGHT
    SETB P1.7 ; DOWN (ENTER BUTTON)
     
     
    EECON EQU 96H
     
    STARTUP:
    MOV A,#38H
    ACALL COMNWRT
    MOV A, #0EH
    ACALL COMNWRT
    MOV A, #01
    ACALL COMNWRT
    MOV A, #06H
    ACALL COMNWRT
    MOV A, #84H ;TO WRITE ON TOP LINE
    ACALL COMNWRT
    MOV A, #'H'
    ACALL DATAWRT
    MOV A, #'E'
    ACALL DATAWRT
    MOV A, #'L'
    ACALL DATAWRT
    MOV A, #'L'
    ACALL DATAWRT
    MOV A, #'O'
    ACALL DATAWRT
    SJMP ENTER2START
     
    ;OPTIONAL SUBROUTINES
    ENTER2START:
    MOV A, #0C1H ;TO WRITE ON BOTTOM LINE
    ACALL COMNWRT
    MOV A, #'E'
    ACALL DATAWRT
    MOV A, #'N'
    ACALL DATAWRT
    MOV A, #'T'
    ACALL DATAWRT
    MOV A, #'E'
    ACALL DATAWRT
    MOV A, #'R'
    ACALL DATAWRT
    MOV A, #' '
    ACALL DATAWRT
    MOV A, #'T'
    ACALL DATAWRT
    MOV A, #'O'
    ACALL DATAWRT
    MOV A, #' '
    ACALL DATAWRT
    MOV A, #'S'
    ACALL DATAWRT
    MOV A, #'T'
    ACALL DATAWRT
    MOV A, #'A'
    ACALL DATAWRT
    MOV A, #'R'
    ACALL DATAWRT
    MOV A, #'T'
    ACALL DATAWRT
    WAIT4USER: ;waits for physical input
    JNB P1.7, SP1
    SJMP WAIT4USER
     
     
    SP1:
    ACALL CLEARDISP
    MOV A, #80H ;TO WRITE ON TOP LINE
    ACALL COMNWRT
    MOV A, #' '
    ACALL DATAWRT
    MOV A, #' '
    ACALL DATAWRT
    MOV A, #' '
    ACALL DATAWRT
    MOV A, #' '
    ACALL DATAWRT
    MOV A, #' '
    ACALL DATAWRT
    MOV A, #'S'
    ACALL DATAWRT
    MOV A, #'O'
    ACALL DATAWRT
    MOV A, #'C'
    ACALL DATAWRT
    MOV A, #'C'
    ACALL DATAWRT
    MOV A, #'E'
    ACALL DATAWRT
    MOV A, #'R'
    ACALL DATAWRT
    MOV A, #' '
    ACALL DATAWRT
    MOV A, #' '
    ACALL DATAWRT
    MOV A, #'-'
    ACALL DATAWRT
    MOV A, #'-'
    ACALL DATAWRT
    MOV A, #'>'
    ACALL DATAWRT
    ACALL READSAVEDPREF
     
     
    SP1WAIT: ;waits for physical input
    JNB P1.6, SP1SP2 ;RIGHT BUTTON
    JNB P1.4, SP1C1 ;UP BUTTON (BACK)
    JNB P1.5, SP1LIKE ;CENTER BUTTON (LIKE/DISLIKE BUTTON)
    ACALL SP1WAIT
    SP1SP2: SJMP SP1
    SP1C1: SJMP SP1WAIT
    SP1LIKE:LJMP TOGGLEPREF
     
    ;COMMON SUBROUTINES
     
    CLEARDISP:
    MOV A, #01H
    ACALL COMNWRT
    RET
     
    COMNWRT: ;WITH DOUBLE DELAY
    MOV P2, A
    CLR P3.2
    CLR P3.3
    SETB P3.4
    ACALL DELAY
    CLR P3.4
    ACALL DELAY
    RET
     
    DATAWRT: ;FOLLOWS UP WITH DELAY
    MOV P2, A
    SETB P3.2
    CLR P3.3
    SETB P3.4
    ACALL DELAY
    CLR P3.4
    DELAY:
    MOV R3, #50
    HERE2:
    MOV R4, #255
    HERE:
    DJNZ R4, HERE
    DJNZ R3, HERE2
    RET
     
     
    READSAVEDPREF:
     
    ORL EECON,#00001000b
    mov DPTR,#10H ;point to the memory location needed to read from. Chosen location 0
    movx A,@dptr ;move the data within the memory location to the Accumulator
    ;mov R0,A ;move the data within Accumulator to the Register
    XRL EECON,#00000000B
     
    COMPARE:CJNE A, #01010101B, DISLIKE ;CHG DATA TO THE DATA TO BE COMPARED
    ACALL LIKE
     
     
    TOGGLEPREF: ;ROTATES THE BINARY TO THE LEFT AND COMPARES.
     
    ORL EECON,#00001000b
    mov DPTR,#10H ;point to the memory location needed to read from. Chosen location 0
    movx A,@dptr ;move the data within the memory location to the Accumulator
    ;mov R0,A ;move the data within Accumulator to the Register
    XRL EECON,#00000000B ;move the data within Accumulator to the Register
    RR A
    CJNE A, #01010101B, DISLIKE ;COMPARES WITH LIKE, IF COMPARISON ISN'T LIKE, WILL JUMP TO DISLIKE.
    SJMP LIKE
     
    DISLIKE:
     
    ORL EECON,#00001000b
    ORL EECON,#00010000B
     
    mov dptr,#10H ;point to the memory location needed to write to. chosen location 0
    mov a,#10101010B ;move the data (0fch) to Accumulator
    movx @dptr,a ;write the data to the chosen location
     
    XRL EECON, #00010000B
    XRL EECON, #00000000B
     
    MOV A, #0C5H ;TO WRITE ON BOTTOM LINE
    ACALL COMNWRT
    MOV A, #'D'
    ACALL DATAWRT
    MOV A, #'I'
    ACALL DATAWRT
    MOV A, #'S'
    ACALL DATAWRT
    MOV A, #'L'
    ACALL DATAWRT
    MOV A, #'I'
    ACALL DATAWRT
    MOV A, #'K'
    ACALL DATAWRT
    MOV A, #'E'
    ACALL DATAWRT
    LJMP SP1WAIT
     
    LIKE:
     
     
    ORL EECON,#00001000b
    ORL EECON,#00010000B
     
    mov dptr,#10H ;point to the memory location needed to write to. chosen location 0
    mov a,#01010101B ;move the data (0fch) to Accumulator
    movx @dptr,a ;write the data to the chosen location
     
    XRL EECON, #00010000B
    XRL EECON, #00000000B
     
    MOV A, #0C5H ;TO WRITE ON BOTTOM LINE
    ACALL COMNWRT
    MOV A, #' '
    ACALL DATAWRT
    MOV A, #'L'
    ACALL DATAWRT
    MOV A, #'I'
    ACALL DATAWRT
    MOV A, #'K'
    ACALL DATAWRT
    MOV A, #'E'
    ACALL DATAWRT
    MOV A, #' '
    ACALL DATAWRT
    MOV A, #' '
    ACALL DATAWRT
    LJMP SP1WAIT
     
    ;INTERRUPT ROUTINES
     
    EXT_0:
     
    RETI
     
    EXT_1:
     
    RETI
     
    TIMER_0:
     
    RETI
     
    TIMER_1:
     
    RETI
     
    END

     

     

    August 19, 2014 at 9:51 am #12038
    Ashutosh Bhatt
    Participant

    on which EEPROM you are storing user preferences? r u using serial EEPROM?

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Back to the old BASIC days May 24, 2025
  • Fluke 123 scopemeter not reading ANY voltage, please help May 24, 2025
  • Capacitive Touch On The Profile May 24, 2025
  • Cpu coin acceptor and zero delay arcade board. May 24, 2025
  • Actin group needed for effective PCB software tutorials May 24, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise