Writting at different object location


#1

Hi evrybody,
I am writing some data at different object location but I got some error I am giving code as follows
void onesec_timerhandler(u8 TimerId)
{
freq1++;

adl_flhWrite (FlashHandle,0,1, &freq1); 
TRACE((1," Frequency0: %d " , freq1));
adl_flhRead(FlashHandle,0,1,&Readdata0);
TRACE((1," Readdata0: %d ",Readdata0));
//TRACE((1," Readdata0 address: %d ",0));

freq1++;
adl_flhWrite (FlashHandle,1,1, &freq1); 
TRACE((1," Frequency1: %d " , freq1));
adl_flhRead(FlashHandle,1,1,&Readdata1);
TRACE((1," Readdata1: %d ",Readdata1));
//TRACE((1," Readdata1 address: %d ",1));

freq1++;
adl_flhWrite (FlashHandle,2,1, &freq1); 
TRACE((1," Frequency1: %d " , freq1));
adl_flhRead(FlashHandle,2,1,&Readdata2);
TRACE((1," Readdata2: %d ",Readdata2));
//TRACE((1," Readdata2 address: %d ",1));

freq1++;
adl_flhWrite (FlashHandle,3,1, &freq1); 
TRACE((1," Frequency3: %d " , freq1));
adl_flhRead(FlashHandle,3,1,&Readdata3);
TRACE((1," Readdata3: %d ",Readdata3));
//TRACE((1," Readdata3 address: %d ",1));

freq1++;
adl_flhWrite (FlashHandle,4,1, &freq1); 
TRACE((1," Frequency4: %d " , freq1));
adl_flhRead(FlashHandle,4,1,&Readdata4);
TRACE((1," Readdata4: %d ",Readdata4));
//TRACE((1," Readdata1 address: %d ",1));

freq1++;
adl_flhWrite (FlashHandle,5,1, &freq1); 
TRACE((1," Frequency5: %d " , freq1));
adl_flhRead(FlashHandle,5,1,&Readdata5);
TRACE((1," Readdata5: %d ",Readdata5));
//TRACE((1," Readdata5 address: %d ",1));

freq1++;
adl_flhWrite (FlashHandle,6,1, &freq1); 
TRACE((1," Frequency6: %d " , freq1));
adl_flhRead(FlashHandle,6,1,&Readdata6);
TRACE((1," Readdata6: %d ",Readdata6));
//TRACE((1," Readdata6 address: %d ",1));

freq1++;
adl_flhWrite (FlashHandle,7,1, &freq1); 
TRACE((1," Frequency7: %d " , freq1));
adl_flhRead(FlashHandle,7,1,&Readdata7);
TRACE((1," Readdata7: %d ",Readdata7));
//TRACE((1," Readdata7 address: %d ",1));

freq1++;
adl_flhWrite (FlashHandle,8,1, &freq1); 
TRACE((1," Frequency8: %d " , freq1));
adl_flhRead(FlashHandle,8,1,&Readdata8);
TRACE((1," Readdata8: %d ",Readdata8));
//TRACE((1," Readdata8 address: %d ",1));

freq1++;
adl_flhWrite (FlashHandle,9,1, &freq1); 
TRACE((1," Frequency9: %d " , freq1));
adl_flhRead(FlashHandle,9,1,&Readdata9);
TRACE((1," Readdata9: %d ",Readdata9));
//TRACE((1," Readdata9 address: %d ",1));

}
The traces I got on the Target monitoring tools are
Trace IP 1 Embedded Application : Main
Trace IP 1 Frequency0: 11
Trace IP 1 Readdata0: 11
Trace IP 1 Frequency1: 12
Trace IP 1 Readdata1: 12
Trace IP 1 Frequency1: 13
Trace IP 1 Readdata2: 13
Trace IP 1 Frequency3: 14
Trace IP 1 Readdata3: 0
Trace IP 1 Frequency4: 15
Trace IP 1 Readdata4: 0
Trace IP 1 Frequency5: 16
Trace IP 1 Readdata5: 0
Trace IP 1 Frequency6: 17
Trace IP 1 Readdata6: 0
Trace IP 1 Frequency7: 18
Trace IP 1 Readdata7: 0
Trace IP 1 Frequency8: 19
Trace IP 1 Readdata8: 0
Trace IP 1 Frequency9: 20
Trace IP 1 Readdata9: 0

Here I was able to read fist three objects. what happened to other 7 objects. Has any body done this

Rahul.


#2

Hi,

I’ve seen before that the flash routines (read and write) takes some time to finish.

I think your code should work better if you do not make that many consecutive calls to write and read.

I dont think it matter that you only write a single byte each time, the routines have a certain minimum time to setup and complete its execution.

I’ve not seen any detailed figures about this timing but my experience is that its better to write a large chunk of data more seldom than small data often.

And remember, the flash memory only has a limited guaranteed lifetime (typical value: about 100.000 read and write cycles…
and with one cycle every second and you reach 100.000 after 27,7 hours…

/Snoooze