How do I troubleshoot my EEPROM test code problem?

  • Thread starter Thread starter NexusRevZ
  • Start date Start date
  • Tags Tags
    Code Test
AI Thread Summary
The discussion centers on troubleshooting EEPROM test code for an AT89S8253 microcontroller. The code attempts to write a specific binary value to EEPROM and then read it back, with LED indicators signaling success or failure. Key issues include potential memory locking at address 0, where the program is stored, and problems with EEPROM control register settings that lead to unintended jumps in the code. Suggestions include changing the memory address for writing and ensuring proper comments in the code for clarity. The conversation highlights the importance of understanding assembly language intricacies for effective debugging.
NexusRevZ
Messages
4
Reaction score
0
This simple code is test the write and read of EEPROM.



Firstly the LED at P1 will have all LED on, after a sec, have the P1 will have LED on.

Next, code is to write 01010101B into the EEPROM.

CJNE will check to see if it is written.

But, after comparing, the data isn't similar and the code is restarted.



If the writing process works the LED at P1.0 should be the only LED on, which will notify the success of writing into the EEPROM.



The next portion of the code will recall/read the written data in the EEPROM.

f it is able to read, P1 will have alternate LED on and off.

Please provide solutions, sources and why or what I had done wrong, to educate me. Thank you.

=============================

org 0
jmp start
eecon EQU 96h

start:
MOV A,#11111111B
MOV P1,A
ACALL DELAY0
MOV A,#00001111B
MOV P1,A
ACALL DELAY0

WRITE:
MOV EECON,#00001000b

mov dptr,#0 ;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

MOVX A, @DPTR
CJNE A, #10101010B, START

WRITEFIN:
MOV A,#00000001B
MOV P1,A
ACALL DELAY0
READ:
MOV EECON,#00001000b
mov DPTR,#0 ;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

WAT: MOV P1,R0
SJMP WAT

;========================================
DELAY0:
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
RET
DELAY:
MOV R3, #255
HERE2:
MOV R4, #255
HERE:
DJNZ R4, HERE
DJNZ R3, HERE2
RET
end
 
Engineering news on Phys.org
What is the microcontroller PICxxxxx ??
 
I am using the microcontroller from ATMEL, AT89S8253.
 
Assembly code is a B***** to read if you know what is going on, near impossible if you don't.
I'd suggest before you try and get other people to help you that you comment each and every line of code.
When I write assembly code pretty much every line has a comment. I know this seems excessive but I find that even when you go back to a block of code that you wrote earlier without comments you'll have a hard time following what's going on.

That being said my guess is that you try and write the data to memory address 0.


NexusRevZ said:
mov dptr,#0 ;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

but that is also where you are storing your program



NexusRevZ said:
org 0

its possible that the chip is locking the memory where the program is stored, that the chip won't allow you to write to the first block of memory.
 
cpscdave said:
That being said my guess is that you try and write the data to memory address 0.

but that is also where you are storing your program

its possible that the chip is locking the memory where the program is stored, that the chip won't allow you to write to the first block of memory.
I kinda...get what you mean..kinda...
So, I'll try "Org 200" and see if it works. Thanks.
 
I have recently changed my code after more online advise from other users. They have told me to refer to this pdf (In Section 3.3) , attached to this post.
But the problem I'm facing is within:

ORL EECON, #EEMEN
ORL EECON, #EEMWE

MOV A, EECON
ANL A, #WRTINH
JZ START


It keeps jumping on to "START". There's an error somewhere there.
=========================================

org 200
jmp start

EECON EQU 096H ; watchdog and memory control register
EEMEN EQU 00001000B ; EEPROM access enable bit
EEMWE EQU 00010000B ; EEPROM write enable bit
EELD EQU 00100000B ; EEPROM page load enable bit
WRTINH EQU 00000001B ; EEPROM WRTINH bit
RDY EQU 00000010B ; EEPROM RDY/BSY bit

START:
MOV A,#11111111B
MOV P1,A
ACALL DELAY0
START1: MOV A,#00001111B
MOV P1,A
ACALL DELAY0
MOV A,#11110000B
MOV P1,A
ACALL DELAY0


WRITE:
ORL EECON, #EEMEN
ORL EECON, #EEMWE

MOV A, EECON
ANL A, #WRTINH
JZ START

mov dptr,#0 ;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

LOOP: MOV A, EECON
ANL A, #RDY
JNZ LOOP

LOOP1: MOV A, EECON
ANL A, #RDY
MOVX A, @DPTR
CJNE A, #10101010B, START1
XRL EECON, #EEMWE
XRL EECON, #EEMEN

WRITEFIN:
MOV A,#00000001B
MOV P1,A
ACALL DELAY0
READ:
MOV EECON,#00001000b
mov DPTR,#0 ;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

WAT: MOV P1,R0
SJMP WAT

;========================================
DELAY0:
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
RET
DELAY:
MOV R3, #255
HERE2:
MOV R4, #255
HERE:
DJNZ R4, HERE
DJNZ R3, HERE2
RET
end
 

Attachments

While I was rolling out a shielded cable, a though came to my mind - what happens to the current flow in the cable if there came a short between the wire and the shield in both ends of the cable? For simplicity, lets assume a 1-wire copper wire wrapped in an aluminum shield. The wire and the shield has the same cross section area. There are insulating material between them, and in both ends there is a short between them. My first thought, the total resistance of the cable would be reduced...
Hi all I have some confusion about piezoelectrical sensors combination. If i have three acoustic piezoelectrical sensors (with same receive sensitivity in dB ref V/1uPa) placed at specific distance, these sensors receive acoustic signal from a sound source placed at far field distance (Plane Wave) and from broadside. I receive output of these sensors through individual preamplifiers, add them through hardware like summer circuit adder or in software after digitization and in this way got an...
I am not an electrical engineering student, but a lowly apprentice electrician. I learn both on the job and also take classes for my apprenticeship. I recently wired my first transformer and I understand that the neutral and ground are bonded together in the transformer or in the service. What I don't understand is, if the neutral is a current carrying conductor, which is then bonded to the ground conductor, why does current only flow back to its source and not on the ground path...

Similar threads

Back
Top