Microcontroller › 8051 › Read, Write EEPROM problem on AT89S8253
- This topic has 1 reply, 2 voices, and was last updated 10 years, 1 month ago by Ashutosh Bhatt.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
July 29, 2014 at 4:16 am #3855NexusParticipantMy 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 0000HLJMP STARTUPCSEG AT 0003HLJMP EXT_0CSEG AT 000BHLJMP TIMER_0CSEG AT 0013HLJMP EXT_1CSEG AT 001BHLJMP TIMER_1CSEG AT 0036HSETB P1.3 ; LEFTSETB P1.4 ; UP (BACK BUTTON)SETB P1.5 ; CENTER (LIKE/DISLIKE BUTTON)SETB P1.6 ; RIGHTSETB P1.7 ; DOWN (ENTER BUTTON)EECON EQU 96HSTARTUP:MOV A,#38HACALL COMNWRTMOV A, #0EHACALL COMNWRTMOV A, #01ACALL COMNWRTMOV A, #06HACALL COMNWRTMOV A, #84H ;TO WRITE ON TOP LINEACALL COMNWRTMOV A, #'H'ACALL DATAWRTMOV A, #'E'ACALL DATAWRTMOV A, #'L'ACALL DATAWRTMOV A, #'L'ACALL DATAWRTMOV A, #'O'ACALL DATAWRTSJMP ENTER2START;OPTIONAL SUBROUTINESENTER2START:MOV A, #0C1H ;TO WRITE ON BOTTOM LINEACALL COMNWRTMOV A, #'E'ACALL DATAWRTMOV A, #'N'ACALL DATAWRTMOV A, #'T'ACALL DATAWRTMOV A, #'E'ACALL DATAWRTMOV A, #'R'ACALL DATAWRTMOV A, #' 'ACALL DATAWRTMOV A, #'T'ACALL DATAWRTMOV A, #'O'ACALL DATAWRTMOV A, #' 'ACALL DATAWRTMOV A, #'S'ACALL DATAWRTMOV A, #'T'ACALL DATAWRTMOV A, #'A'ACALL DATAWRTMOV A, #'R'ACALL DATAWRTMOV A, #'T'ACALL DATAWRTWAIT4USER: ;waits for physical inputJNB P1.7, SP1SJMP WAIT4USERSP1:ACALL CLEARDISPMOV A, #80H ;TO WRITE ON TOP LINEACALL COMNWRTMOV A, #' 'ACALL DATAWRTMOV A, #' 'ACALL DATAWRTMOV A, #' 'ACALL DATAWRTMOV A, #' 'ACALL DATAWRTMOV A, #' 'ACALL DATAWRTMOV A, #'S'ACALL DATAWRTMOV A, #'O'ACALL DATAWRTMOV A, #'C'ACALL DATAWRTMOV A, #'C'ACALL DATAWRTMOV A, #'E'ACALL DATAWRTMOV A, #'R'ACALL DATAWRTMOV A, #' 'ACALL DATAWRTMOV A, #' 'ACALL DATAWRTMOV A, #'-'ACALL DATAWRTMOV A, #'-'ACALL DATAWRTMOV A, #'>'ACALL DATAWRTACALL READSAVEDPREFSP1WAIT: ;waits for physical inputJNB P1.6, SP1SP2 ;RIGHT BUTTONJNB P1.4, SP1C1 ;UP BUTTON (BACK)JNB P1.5, SP1LIKE ;CENTER BUTTON (LIKE/DISLIKE BUTTON)ACALL SP1WAITSP1SP2: SJMP SP1SP1C1: SJMP SP1WAITSP1LIKE:LJMP TOGGLEPREF;COMMON SUBROUTINESCLEARDISP:MOV A, #01HACALL COMNWRTRETCOMNWRT: ;WITH DOUBLE DELAYMOV P2, ACLR P3.2CLR P3.3SETB P3.4ACALL DELAYCLR P3.4ACALL DELAYRETDATAWRT: ;FOLLOWS UP WITH DELAYMOV P2, ASETB P3.2CLR P3.3SETB P3.4ACALL DELAYCLR P3.4DELAY:MOV R3, #50HERE2:MOV R4, #255HERE:DJNZ R4, HEREDJNZ R3, HERE2RETREADSAVEDPREF:ORL EECON,#00001000bmov DPTR,#10H ;point to the memory location needed to read from. Chosen location 0movx A,@dptr ;move the data within the memory location to the Accumulator;mov R0,A ;move the data within Accumulator to the RegisterXRL EECON,#00000000BCOMPARE:CJNE A, #01010101B, DISLIKE ;CHG DATA TO THE DATA TO BE COMPAREDACALL LIKETOGGLEPREF: ;ROTATES THE BINARY TO THE LEFT AND COMPARES.ORL EECON,#00001000bmov DPTR,#10H ;point to the memory location needed to read from. Chosen location 0movx A,@dptr ;move the data within the memory location to the Accumulator;mov R0,A ;move the data within Accumulator to the RegisterXRL EECON,#00000000B ;move the data within Accumulator to the RegisterRR ACJNE A, #01010101B, DISLIKE ;COMPARES WITH LIKE, IF COMPARISON ISN'T LIKE, WILL JUMP TO DISLIKE.SJMP LIKEDISLIKE:ORL EECON,#00001000bORL EECON,#00010000Bmov dptr,#10H ;point to the memory location needed to write to. chosen location 0mov a,#10101010B ;move the data (0fch) to Accumulatormovx @dptr,a ;write the data to the chosen locationXRL EECON, #00010000BXRL EECON, #00000000BMOV A, #0C5H ;TO WRITE ON BOTTOM LINEACALL COMNWRTMOV A, #'D'ACALL DATAWRTMOV A, #'I'ACALL DATAWRTMOV A, #'S'ACALL DATAWRTMOV A, #'L'ACALL DATAWRTMOV A, #'I'ACALL DATAWRTMOV A, #'K'ACALL DATAWRTMOV A, #'E'ACALL DATAWRTLJMP SP1WAITLIKE:ORL EECON,#00001000bORL EECON,#00010000Bmov dptr,#10H ;point to the memory location needed to write to. chosen location 0mov a,#01010101B ;move the data (0fch) to Accumulatormovx @dptr,a ;write the data to the chosen locationXRL EECON, #00010000BXRL EECON, #00000000BMOV A, #0C5H ;TO WRITE ON BOTTOM LINEACALL COMNWRTMOV A, #' 'ACALL DATAWRTMOV A, #'L'ACALL DATAWRTMOV A, #'I'ACALL DATAWRTMOV A, #'K'ACALL DATAWRTMOV A, #'E'ACALL DATAWRTMOV A, #' 'ACALL DATAWRTMOV A, #' 'ACALL DATAWRTLJMP SP1WAIT;INTERRUPT ROUTINESEXT_0:RETIEXT_1:RETITIMER_0:RETITIMER_1:RETIENDAugust 19, 2014 at 9:51 am #12038Ashutosh BhattParticipant
on which EEPROM you are storing user preferences? r u using serial EEPROM?
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.