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 CCS Technical Support

Fastest/best way to save ext eeprom

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







Fastest/best way to save ext eeprom
PostPosted: Sun Feb 02, 2003 11:24 pm     Reply with quote

I have a problem to save data to external eeprom,ex.every 250 ms.My logger software should calculate time very accurately. I have made inside 1ms clock with timer2 and offen my software work but sometimes my eeprom function didn't write the data.
Should I change inside timer ex. 10ms or 50ms? Or write data different way ?

software:
#INT_TIMER2
void cal() {
counter_ms++;
if(counter_ms==250) save=1;
if(counter_ms==500) save=1;
if(counter_ms==750) save=1;
if(counter_ms==999) save=1;

if(counter_ms>999)
{
counter_sec++;
counter_ms = 0;
}
if(counter_sec>255)
{counter_sec = 0;
}}

//********************
program....
if(save==1)
{ .....
disable_interrupts(GLOBAL);
if(fastest==1){
WRITE_EXT_EEPROM(0x05,fast_sec); //sec
WRITE_EXT_EEPROM(0x06,fast_ms_hi); //ms_hi
WRITE_EXT_EEPROM(0x07,fast_ms_lo); //ms_lo
}
write_ext_eeprom_start(address);

i2c_write(temp_lapCount);
i2c_write(temp_sec);
i2c_write(temp_ms_hi);
i2c_write(temp_ms_lo);
i2c_write(speed);
i2c_stop();
enable_interrupts(GLOBAL);
//delay_ms(6);
address+=5;
......
}}// end if
....
___________________________
This message was ported from CCS's old forum
Original Post ID: 11220
Tomi
Guest







Re: Fastest/best way to save ext eeprom
PostPosted: Mon Feb 03, 2003 5:46 am     Reply with quote

<font face="Courier New" size=-1>What is your EEPROM type and what is about page boundaries?
E.g. if you use 24LC256 then you have 64-byte boundaries. This means that you must pay attention for your code part:
write_ext_eeprom_start(address);
i2c_write(temp_lapCount); // a page boundary violation could occurs from here
i2c_write(temp_sec);
i2c_write(temp_ms_hi);
i2c_write(temp_ms_lo);
i2c_write(speed); // to here
i2c_stop();

I use something like this:
#separate
void IncPutAddr()
{
putaddr++;
if (!(putaddr & 0x3F)) { // if the address is at a boudary
TerminateIIC(); // close I2C session
StartIIC(); // and reopen it
WriteIIC(0xA0);
WriteIIC(putaddrH);
WriteIIC(putaddrL);
}
}
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11225
TSchultz



Joined: 08 Sep 2003
Posts: 66
Location: Toronto, Canada

View user's profile Send private message

RE: Fastest/best way to save ext eeprom
PostPosted: Mon Feb 03, 2003 6:47 am     Reply with quote

:=I have a problem to save data to external eeprom,ex.every 250 ms.My logger software should calculate time very accurately. I have made inside 1ms clock with timer2 and offen my software work but sometimes my eeprom function didn't write the data.
:=Should I change inside timer ex. 10ms or 50ms? Or write data different way ?
:=
:=software:
:=#INT_TIMER2
:=void cal() {
:= counter_ms++;
:= if(counter_ms==250) save=1;
:= if(counter_ms==500) save=1;
:= if(counter_ms==750) save=1;
:= if(counter_ms==999) save=1;
:=
:= if(counter_ms>999)
:= {
:= counter_sec++;
:= counter_ms = 0;
:= }
:= if(counter_sec>255)
:= {counter_sec = 0;
:= }}
:=
:=//********************
:=program....
:=if(save==1)
:= { .....
:= disable_interrupts(GLOBAL);
:= if(fastest==1){
:= WRITE_EXT_EEPROM(0x05,fast_sec); //sec
:= WRITE_EXT_EEPROM(0x06,fast_ms_hi); //ms_hi
:= WRITE_EXT_EEPROM(0x07,fast_ms_lo); //ms_lo
:= }
:= write_ext_eeprom_start(address);
:=
:= i2c_write(temp_lapCount);
:= i2c_write(temp_sec);
:= i2c_write(temp_ms_hi);
:= i2c_write(temp_ms_lo);
:= i2c_write(speed);
:= i2c_stop();
:= enable_interrupts(GLOBAL);
:= //delay_ms(6);
:= address+=5;
:= ......
:=}}// end if
:=....

You may also want to take a look at the FRAM parts from RAMTRON. They are drop-in replacements for the EEPROM but don't have the write delays.

They have one additional drawback in that a read is actually performed as a read and write internally. This means that reading or writing count as a hit against the endurance. This is normally not a problem because they have much higher endurance than EEPROM and their newer, low voltage parts some are listed as having unlimited read/write cycles.

The only change is usually make to the driver is the removal of the write delay.

-Troy
___________________________
This message was ported from CCS's old forum
Original Post ID: 11227
Richard Slater



Joined: 08 Sep 2003
Posts: 12
Location: Cambridge, UK

View user's profile Send private message Visit poster's website

Re: Fastest/best way to save ext eeprom
PostPosted: Mon Feb 03, 2003 9:44 am     Reply with quote

:=I have a problem to save data to external eeprom,ex.every 250 ms.My logger software should calculate time very accurately. I have made inside 1ms clock with timer2 and offen my software work but sometimes my eeprom function didn't write the data.
:=Should I change inside timer ex. 10ms or 50ms? Or write data different way ?
:=
:=software:
:=#INT_TIMER2
:=void cal() {
:= counter_ms++;
:= if(counter_ms==250) save=1;
:= if(counter_ms==500) save=1;
:= if(counter_ms==750) save=1;
:= if(counter_ms==999) save=1;
:=
:= if(counter_ms>999)
:= {
:= counter_sec++;
:= counter_ms = 0;
:= }
:= if(counter_sec>255)
:= {counter_sec = 0;
:= }}
:=
:=//********************
:=program....
:=if(save==1)
:= { .....
:= disable_interrupts(GLOBAL);
:= if(fastest==1){
:= WRITE_EXT_EEPROM(0x05,fast_sec); //sec
:= WRITE_EXT_EEPROM(0x06,fast_ms_hi); //ms_hi
:= WRITE_EXT_EEPROM(0x07,fast_ms_lo); //ms_lo
:= }
:= write_ext_eeprom_start(address);
:=
:= i2c_write(temp_lapCount);
:= i2c_write(temp_sec);
:= i2c_write(temp_ms_hi);
:= i2c_write(temp_ms_lo);
:= i2c_write(speed);
:= i2c_stop();
:= enable_interrupts(GLOBAL);
:= //delay_ms(6);
:= address+=5;
:= ......
:=}}// end if
:=....

You do not show your declarations of the variables 'counter_ms' and 'counter_sec'. If you have declared them as 'int' then this could be part of the problem. They need to be 'long' for the magnitudes you are using.

If they are longs already... please ignore this!


Richard
___________________________
This message was ported from CCS's old forum
Original Post ID: 11231
pete
Guest







Re: Fastest/best way to save ext eeprom
PostPosted: Mon Feb 03, 2003 1:35 pm     Reply with quote

:=<font face="Courier New" size=-1>What is your EEPROM type and what is about page boundaries?

Yes, I use 24LC256 eeprom.

:=E.g. if you use 24LC256 then you have 64-byte boundaries. This means that you must pay attention for your code part:
:=write_ext_eeprom_start(address);
:=i2c_write(temp_lapCount); // a page boundary violation could occurs from here
:=i2c_write(temp_sec);
:=i2c_write(temp_ms_hi);
:=i2c_write(temp_ms_lo);
:=i2c_write(speed); // to here
:=i2c_stop();
:=
:=I use something like this:
:=#separate
:=void IncPutAddr()
:={
:=putaddr++;
:=if (!(putaddr & 0x3F)) { // if the address is at a boudary
:=TerminateIIC(); // close I2C session
:=StartIIC(); // and reopen it
:=WriteIIC(0xA0);
:=WriteIIC(putaddrH);
:=WriteIIC(putaddrL);
:=}
:=}
:=</font>

� have list of my data from eeprom. Maybe boudaries could be the problem, I have to try to change my code and tested.
Thanks.

// I started saving data from address 100
0,0:252,0 // lap(int),sec(int):ms(long),rpm(int) ...
0,0:504,0
0,0:751,0
0,1: 3,0
0,1:255,0
0,1:258,238 // first mistake !Should be 1,1:50?,0
0,1:753,0
0,2: 0,0
0,2:252,0
0,2:504,0
0,2:750,0
0,3: 3,0
0,3:254,0
0,3:501,0
0,3:753,0
0,4: 0,0
0,4:251,0
0,4:503,0
0,4:768,3
0,5: 2,0
0,0:252,0
0,0:504,0
0,0:750,0
0,1: 3,0
0,1:255,0
0,1:501,0
0,1:753,0
0,2: 0,0
0,2:252,0
0,2:503,0
0,2:750,0
0,255:535,255 //second one ! 0,3:0,0
0,3:254,0
0,3:500,0
0,3:753,0
0,4: 0,0
0,4:251,0
0,4:503,0
0,4:755,0
0,5: 2,0
0,5:254,0
0,5:500,0
0,5:752,0
0,5:999,0
0,6:255,0
0,6:503,0
0,6:752,0
0,7: 1,0
0,7:257,0
0,7:505,0
0,7:754,0
0,8: 3,0
0,8:251,0
0,8:500,0
0,8:756,0
0,9: 6,0
0,9:254,248 // third one .... and you can see more under
0,9:502,0
0,9:751,0
0,10: 0,0
0,10:256,0
0,10:505,0
0,10:754,0
0,11: 3,0
0,11:252,0
0,11:501,0
0,11:757,0
0,11:999,0
0,12:255,0
0,12:258,244
0,12:753,0
0,13: 3,0
0,13:251,0
0,13:500,0
0,13:757,0
0,13:999,0
0,14:255,0
0,14:503,0
0,14:752,0
0,15: 2,0
0,15:251,0
0,15:507,0
0,15:864,1
0,16: 6,0
0,16:254,0
0,16:503,0
0,16:752,0
0,17: 1,0
0,17:250,0
0,17:506,0
0,17:755,0
0,18: 5,0
0,18:253,0
0,18:502,0
0,18:751,0
0,255:535,255
0,19:257,0
0,19:506,0
0,19:755,0
0,20: 4,0
0,20:253,0
0,20:501,0
0,20:750,0
0,21: 0,0
0,21:256,0
0,21:505,0
0,21:754,0
0,22: 4,0
0,22:252,0
0,22:501,0
0,22:750,0
0,22:999,0
0,23:256,0
0,23:504,0
0,23:753,0
0,24: 3,0
0,24:251,0
0,24:500,0
0,24:757,0
0,24:999,0
0,25:255,250
0,25:504,0
0,25:753,0
0,26: 2,0
0,26:251,0
0,26:507,0
0,26:756,0
0,27: 6,0
0,27:254,0
0,27:503,0
0,27:752,0
0,28: 2,0
0,28:250,0
0,28:258,241
0,28:755,0
0,29: 5,0
0,29:253,0
0,29:502,0
0,29:751,0
0,30: 1,0
0,30:250,0
0,30:506,0
0,30:756,0
0,31: 6,0
0,31:255,0
0,31:504,0
0,31:514,239
0,32: 3,0
0,32:203,0
1,0:250,0
1,0:502,0
1,0:754,0
1,1: 1,0
1,1:252,0
1,1:504,0
1,1:750,0
1,2: 2,0
1,2:254,0
1,2:505,0
1,255:535,255
1,3: 4,0
1,3:255,0
1,3:501,0
1,3:753,0
1,4: 0,0
1,4:251,0
1,4:502,0
1,4:754,0
1,5: 1,0
1,5:253,0
1,5:504,0
1,5:751,0
0,6: 4,0
1,6:250,0
1,6:505,0
1,6:752,0
1,7: 0,0
1,7:254,0
1,7:501,0
1,7:756,0
1,8: 4,0
1,8:251,0
1,8:505,0
1,8:753,0
1,9: 1,255
0,9:255,0
1,9:502,0
1,9:757,0
1,10: 5,0
1,10:252,0
1,10:507,0
1,10:754,0
1,11: 2,0
1,11:257,0
1,11:504,0
1,11:752,0
1,12: 0,0
1,12: 1,247
0,12:502,0
.....
___________________________
This message was ported from CCS's old forum
Original Post ID: 11239
pete
Guest







Re: Fastest/best way to save ext eeprom
PostPosted: Mon Feb 03, 2003 1:39 pm     Reply with quote

:=:=I have a problem to save data to external eeprom,ex.every 250 ms.My logger software should calculate time very accurately. I have made inside 1ms clock with timer2 and offen my software work but sometimes my eeprom function didn't write the data.
:=:=Should I change inside timer ex. 10ms or 50ms? Or write data different way ?
:=:=
:=:=software:
:=:=#INT_TIMER2
:=:=void cal() {
:=:= counter_ms++;
:=:= if(counter_ms==250) save=1;
:=:= if(counter_ms==500) save=1;
:=:= if(counter_ms==750) save=1;
:=:= if(counter_ms==999) save=1;
:=:=
:=:= if(counter_ms>999)
:=:= {
:=:= counter_sec++;
:=:= counter_ms = 0;
:=:= }
:=:= if(counter_sec>255)
:=:= {counter_sec = 0;
:=:= }}
:=:=
:=:=//********************
:=:=program....
:=:=if(save==1)
:=:= { .....
:=:= disable_interrupts(GLOBAL);
:=:= if(fastest==1){
:=:= WRITE_EXT_EEPROM(0x05,fast_sec); //sec
:=:= WRITE_EXT_EEPROM(0x06,fast_ms_hi); //ms_hi
:=:= WRITE_EXT_EEPROM(0x07,fast_ms_lo); //ms_lo
:=:= }
:=:= write_ext_eeprom_start(address);
:=:=
:=:= i2c_write(temp_lapCount);
:=:= i2c_write(temp_sec);
:=:= i2c_write(temp_ms_hi);
:=:= i2c_write(temp_ms_lo);
:=:= i2c_write(speed);
:=:= i2c_stop();
:=:= enable_interrupts(GLOBAL);
:=:= //delay_ms(6);
:=:= address+=5;
:=:= ......
:=:=}}// end if
:=:=....
:=
:=You do not show your declarations of the variables 'counter_ms' and 'counter_sec'. If you have declared them as 'int' then this could be part of the problem. They need to be 'long' for the magnitudes you are using.
:=
:=If they are longs already... please ignore this!
:=
:=
:=Richard

This is my declarations:
...
static long counter_ms;
static int counter_sec;
static int counter_kierrokset;
static long wheel_run;
....
I try before long variables but change to save a little memory.
Thanks,
Pete
___________________________
This message was ported from CCS's old forum
Original Post ID: 11240
Richard Slater



Joined: 08 Sep 2003
Posts: 12
Location: Cambridge, UK

View user's profile Send private message Visit poster's website

Re: Fastest/best way to save ext eeprom
PostPosted: Tue Feb 04, 2003 3:40 am     Reply with quote

:=:=:=I have a problem to save data to external eeprom,ex.every 250 ms.My logger software should calculate time very accurately. I have made inside 1ms clock with timer2 and offen my software work but sometimes my eeprom function didn't write the data.
:=:=:=Should I change inside timer ex. 10ms or 50ms? Or write data different way ?
:=:=:=
:=:=:=software:
:=:=:=#INT_TIMER2
:=:=:=void cal() {
:=:=:= counter_ms++;
:=:=:= if(counter_ms==250) save=1;
:=:=:= if(counter_ms==500) save=1;
:=:=:= if(counter_ms==750) save=1;
:=:=:= if(counter_ms==999) save=1;
:=:=:=
:=:=:= if(counter_ms>999)
:=:=:= {
:=:=:= counter_sec++;
:=:=:= counter_ms = 0;
:=:=:= }
:=:=:= if(counter_sec>255)
:=:=:= {counter_sec = 0;
:=:=:= }}
:=:=:=
:=:=:=//********************
:=:=:=program....
:=:=:=if(save==1)
:=:=:= { .....
:=:=:= disable_interrupts(GLOBAL);
:=:=:= if(fastest==1){
:=:=:= WRITE_EXT_EEPROM(0x05,fast_sec); //sec
:=:=:= WRITE_EXT_EEPROM(0x06,fast_ms_hi); //ms_hi
:=:=:= WRITE_EXT_EEPROM(0x07,fast_ms_lo); //ms_lo
:=:=:= }
:=:=:= write_ext_eeprom_start(address);
:=:=:=
:=:=:= i2c_write(temp_lapCount);
:=:=:= i2c_write(temp_sec);
:=:=:= i2c_write(temp_ms_hi);
:=:=:= i2c_write(temp_ms_lo);
:=:=:= i2c_write(speed);
:=:=:= i2c_stop();
:=:=:= enable_interrupts(GLOBAL);
:=:=:= //delay_ms(6);
:=:=:= address+=5;
:=:=:= ......
:=:=:=}}// end if
:=:=:=....
:=:=
:=:=You do not show your declarations of the variables 'counter_ms' and 'counter_sec'. If you have declared them as 'int' then this could be part of the problem. They need to be 'long' for the magnitudes you are using.
:=:=
:=:=If they are longs already... please ignore this!
:=:=
:=:=
:=:=Richard
:=
:=This is my declarations:
:=...
:=static long counter_ms;
:=static int counter_sec;
:=static int counter_kierrokset;
:=static long wheel_run;
:=....
:=I try before long variables but change to save a little memory.
:=Thanks,
:=Pete

Hi there,

If you have already tried longs, then it is a different problem, but if you wish to use the expression
'if(counter_sec >255){...' then you will need to use longs, as 255 is the largest number that can be represented using an eight bit number, and anything larger than that will just wrap around, and introduce bugs.

Sorry this does not help you actual problem, though!

Richard
___________________________
This message was ported from CCS's old forum
Original Post ID: 11262
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