lmercor
Joined: 31 May 2007 Posts: 20
|
internal eeprom issue (pic16f877a) |
Posted: Tue Jun 19, 2007 12:24 pm |
|
|
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
|
|
Posted: Tue Jun 19, 2007 12:40 pm |
|
|
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:
This will always be true. The loop will never exit. |
|