How do I troubleshoot my EEPROM test code problem?

  • Thread starter NexusRevZ
  • Start date
  • Tags
    Code Test
In summary, the code is testing the write and read functionalities of the EEPROM by first turning on all LEDs at P1, then writing a specific data (01010101B) into the EEPROM. The code then checks to see if the data was successfully written by comparing it with the data in the memory location. If the data is different, the code is restarted. If the writing process is successful, the code will then turn on only one LED at P1.0 to indicate the success. The code then proceeds to read the data from the EEPROM and alternate the LEDs at P1 on and off. The issue with the code is within the section that enables EEPROM access and write, as it keeps jumping to the "START" label.
  • #1
NexusRevZ
4
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
  • #2
What is the microcontroller PICxxxxx ??
 
  • #3
I am using the microcontroller from ATMEL, AT89S8253.
 
  • #4
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.
 
  • #5
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.
 
  • #6
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

  • doc3655_2.pdf
    255.8 KB · Views: 439

What is an EEPROM test code problem?

An EEPROM (Electrically Erasable Programmable Read-Only Memory) test code problem refers to an issue with the programming or function of the EEPROM in an electronic device. This can result in errors or malfunctions in the device's performance.

What causes an EEPROM test code problem?

An EEPROM test code problem can be caused by a variety of factors, including faulty programming, physical damage to the EEPROM, or electrical interference. It can also be the result of incorrect coding or errors in the device's firmware.

How can an EEPROM test code problem be detected?

An EEPROM test code problem can be detected through various methods, such as running diagnostic tests on the device, using specialized software, or examining the device's error logs. In some cases, the problem may also be indicated by error messages or unusual behaviors from the device.

What are the consequences of an EEPROM test code problem?

The consequences of an EEPROM test code problem can vary depending on the severity of the issue and the function of the device. In some cases, it may result in minor errors or glitches that can be resolved easily. However, it can also lead to more significant malfunctions or even render the device unusable.

How can an EEPROM test code problem be fixed?

The solution to an EEPROM test code problem will depend on the specific cause of the issue. In some cases, it may be possible to reprogram the EEPROM or replace it entirely. It may also be necessary to troubleshoot and fix any underlying issues that contributed to the problem. It is best to consult a professional or refer to the device's documentation for guidance on resolving an EEPROM test code problem.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
Back
Top