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.

[51] AT89C2051 interface with EEprom 24C08,In for loop it wont write the data.

Status
Not open for further replies.

yuvarajbe

Newbie level 5
Joined
Nov 12, 2013
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
79
Hi
I am working Interface EEPROM 24C08 with AT89C2051 controller.
I wrote some code for Read/Write the Values(0 to 9) in 24C08.
I am starting with Just counter program which shows Read/Write Values in BCD 7 segment.
Here Problem is for first time it works well when I press P3^5 button.After enter into forloop It wont execute the Read/write operation.For your refernce i have attached Code and simulation which i done.

code:

Code C - [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
#include "Includes.h"
sbit enter = P3^5;
 
 
void delay_ms1(int);           // Function prototype declaration
 
int a[10]={0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90}; 
 
 
 
void main (void)
{
unsigned char RxByte,chh1,chh2,c2,c1;
 
    unsigned char RxByte1;
//        
  if(enter==0){
     
     chh2=2+'0';
    
    
      
        
    Write_Byte_To_24LC64_EEPROM(0x0002, chh2);
 
        }
      
    // Read from 0x0001 address from EEPROM     
    RxByte1 = Read_Byte_From_24LC64_EEPROM(0x0002); 
    // Read from 0x0001 address from EEPROM     
    [ATTACH=CONFIG]135696._xfImport[/ATTACH]    
       P1=0x04;
   P1=P1|(a[RxByte1]);
     delay_ms1(1000);
 
   for (c1=(RxByte1);c1<10;c1++)
   {
    
    
   Write_Byte_To_24LC64_EEPROM(0x0001,c1+0x30);[B]//here is the Problem.It wont write in EEPROM[/B]
   P1=0x04;
   P1=P1|(a[c1]);
     delay_ms1(1000);
       
   }
 
     ////////////////////////////END////////////////////////////
 
  } 
 
     
void delay_ms1(int secc)
{
    int j1;
    int i1;
    for(i1=0;i1<secc;i1++)
    {
        for(j1=0;j1<110;j1++)
        {
        }
    }
}

 
Last edited by a moderator:

andre_luis

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,316
Helped
1,166
Reputation
2,351
Reaction score
1,152
Trophy points
1,403
Location
Brazil
Activity points
54,307
You are trying to interface with the 24C08 device using the code wrote for the 24C64 device; Both are not completelly compatible: The first one uses just 1 byte address whereas the second one uses 2 byte addresses.
 

yuvarajbe

Newbie level 5
Joined
Nov 12, 2013
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
79
Hi
Thanks for ur reply.

I changed address into 2byte. then also It wont write inside the for loop. but outside the loop Read/write operation works well.here I change the code shown below.

code:

Code C - [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
#include "Includes.h"
sbit enter = P3^5;
 
 
void delay_ms1(int);           // Function prototype declaration
 
int a[10]={0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90}; 
 
 
 
void main (void)
{
unsigned char RxByte,chh1,chh2,c2,c1;
 
    unsigned char RxByte1;
//        
  if(enter==0){
     
     chh2=2+'0';
    
    
      
        
    Write_Byte_To_24LC64_EEPROM(0x02, chh2);
 
        }
      
    // Read from 0x01 address from EEPROM     
    RxByte1 = Read_Byte_From_24LC64_EEPROM(0x02); 
    // Read from 0x01 address from EEPROM



View attachment 135696


Code C - [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
P1=0x04;
   P1=P1|(a[RxByte1]);
     delay_ms1(1000);
 
   for (c1=(RxByte1);c1<10;c1++)
   {
    
    
   Write_Byte_To_24LC64_EEPROM(0x02,c1+0x30);[B]//here is the Problem.It wont write in EEPROM[/B]
   P1=0x04;
   P1=P1|(a[c1]);
     delay_ms1(1000);
       
   }
 
     ////////////////////////////END////////////////////////////
 
  } 
 
     
void delay_ms1(int secc)
{
    int j1;
    int i1;
    for(i1=0;i1<secc;i1++)
    {
        for(j1=0;j1<110;j1++)
        {
        }
    }
}

 
Last edited by a moderator:

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
21,071
Helped
4,530
Reputation
9,072
Reaction score
4,624
Trophy points
1,393
Activity points
139,068
Hi,

I don't see that it checks "busy" flag. Instead it uses nasty busy waits.
They are very long in time and draw 100% processing power.
I rather think therefore your program misses some data to read from your serial port than to write it to EEPROM.

Klaus

Btw: There are a lot of discussions about 24xx EEPROM including code here in this forum.
 

yuvarajbe

Newbie level 5
Joined
Nov 12, 2013
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
79
Thanks for supporting me.

Its working.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top