|
|
View previous topic :: View next topic |
Author |
Message |
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Fri May 07, 2004 3:04 am |
|
|
One quick thing: I strongly recommend you to define these two functions and use them instead:
Code: |
void my_write_eeprom(byte Adress, byte Value)
{
write_eeprom(Address,Value);
}
byte my_read_eeprom(byte Adress)
{
return read_eeprom(Adress);
}
|
Now if you use my_write_eeprom() and my_read_eeprom() your code will be MUCH smaller. |
|
|
the_real_maniac Guest
|
|
Posted: Sat Jul 16, 2005 1:50 pm |
|
|
// ->> ! My english is bad so I hope you understand me. <<- !
I'm have little experience with C , but I almost learnt the basics of C, so here is and my sugestion ;)
Why you don't use bit fields and write the struct at onse ?
example:
struct sometype {
int num;
char ch;
}structname;
and something similar to fread(structname, sizeof(structname), 1, fd);
this reads size_t -> sizeof bytes from fd ... and keep them in structname and you have (default) 8 bits num and 8 bits ch -> 2 bYtes (16bits).
And if you have number like 20 -> 2^2 -> i.e 2 bits and you don't need the whole 8 bits you can use bit fields and in this way to small the used memory at all.
And in main program (program ROM) and when writing the struct in EEPROM.
for example
int num : 2
int char : 7
now you saved almost 1 byte 6+1 = 7 bits of ram just example.
when you read / write to EEPROM this saves time and ram
when you make the main program and write it to program RAM you save space/ memory again.
I hope you understand me , of course is posible i have some misunderstand and the whole my idea is wrong , but "you have to try"
Good luck !
if you have to contact me ;)
the [dot] real [dot] maniac [at] gmail [dot] com |
|
|
|
|
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
|