Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to use flash memory of 89C51 to save and read data?

Status
Not open for further replies.
8951's flash memory is the program memory, you can't use it to store data.
 

Thank you all. So i have to use external EEPROM for storing the data. Right???
 

Actually i am not familiar with eeprom programming. Can you give some sample programs in assembly??
 

this example use AT24C256. pin 1, 2, 3, 4, 7 are connected to ground,


Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Read_EEPROM:
        Acall I2C_Start
        Mov A,#0A0h
        Acall I2C_Write
        Mov A,Dph
        Acall I2C_Write
        Mov A,Dpl
        Acall I2C_Write
 
        Acall I2C_Start
        Mov A,#0A1h
        Acall I2C_Write
        Acall I2C_Read
        Acall I2C_Stop
        Ret
 
Write_EEPROM:
        Push Acc
        Acall I2C_Start
        Mov A,#0A0h
        Acall I2C_Write
        Mov A,Dph
        Acall I2C_Write
        Mov A,Dpl
        Acall I2C_Write
        Pop Acc
        Acall I2C_Write
        Acall I2C_Stop
        Ret
 
I2C_Start:
        Setb SDA
        Nop
        Nop
        Nop
        Nop
        Setb SCL
        Nop
        Nop
        Nop
        Nop
        Clr SDA
        Nop
        Nop
        Nop
        Nop
        Clr SCL
        Ret
 
I2C_Stop:
        Clr SDA
        Nop
        Nop
        Nop
        Nop
        Clr SCL
        Nop
        Nop
        Nop
        Nop
        Setb SCL
        Nop
        Nop
        Nop
        Nop
        Setb SDA
        Ret
 
I2C_Write:
        Mov B,#08h
I2C_Write_B:
        Rlc A
        Mov SDA,C
        Setb SCL
        Clr SCL
        Setb SDA
        Djnz B,I2C_Write_B
 
        Mov C,SDA
        Setb SCL
        Clr SCL
        Ret
 
I2C_Read:
        Mov B,#08h
I2C_Read_B:
        Mov C,SDA
        Setb SCL
        Mov C,SDA
        Rlc A
        Clr SCL
        Djnz B,I2C_Read_B
        Mov C,SDA
        Setb SCL
        Clr SCL
        Ret


write single byte of eeprom need 10 ms except we use page writing.
 
Ok friend. How we can see the data locations in simulation? Is that possible?
 

Ok friend. How we can see the data locations in simulation? Is that possible?
I don't know for this. It depends on any simulator's facility.

I forgot to tell you how to use those

Code ASM - [expand]
1
2
3
4
5
6
7
8
;To write data to EEPROM location 1234h, source at accumulator
Mov Dptr,#1234h
Mov A,#15h
Acall Write_EEPROM
;-------------------------------------------------------
;To read data from EEPROM location 5678h, result is at accumulator
Mov Dptr,#5678h
Acall Read_EEPROM

 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top