CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

internal eeprom issue (pic16f877a)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
lmercor



Joined: 31 May 2007
Posts: 20

View user's profile Send private message

internal eeprom issue (pic16f877a)
PostPosted: Tue Jun 19, 2007 12:24 pm     Reply with quote

I have this problem, I want to write data in different address like this

0x2100 AA BB CC DD EE
0x2108 AA BB CC DD EE
0x2110 AA BB CC DD EE
0x2118 AA BB CC DD EE
0x2120 AA BB CC DD EE

just to test my code but what happens is that only writes the first line 0x2100 and the other does not change.



Code:

void write(int8* data, int8 direccion) {
  int i;
   while(direccion<(direccion+5))
 {
     for(i=0;i<=4;i++) {
       write_eeprom((i+direccion),data[i]);
     }
 }
     }

void main(void) {
   int8 code[5];
   int8 puerto;
   set_tris_b(0x0f);
   code[0]=0xaa;
   code[1]=0xbb;
   code[2]=0xcc;
   code[3]=0xdd;
   code[4]=0xee;

 while(TRUE)
 {
puerto=input_b();
switch (puerto)
{
case 1:
write(code,0);
break;

case 2:
write(code,8);
break;

case 3:
write(code,16);
break;

case 4:
write(code,24);
break;

case 5:
write(code,32);
break;
}
}
   }



as I said I'm using the pic16f877a and the version of the compiler is 4.013. I don't know why only writes the firts one, please a little help whit this.

Thanks.


Last edited by lmercor on Tue Jun 19, 2007 2:56 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 19, 2007 12:40 pm     Reply with quote

Quote:
void write(int8* data, int8 direccion) {
int i;
while(direccion<(direccion+5)) {
for(i=0;i<=4;i++) {
write_eeprom((i+direccion),data[i]);
}
}
}


Suppose direccion = 0. Then your while() statement becomes:
Code:
while(0 < 5)

This will always be true. The loop will never exit.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group