View previous topic :: View next topic |
Author |
Message |
deepakomanna
Joined: 06 Mar 2007 Posts: 92 Location: Pune,India
|
byte allocation for numbers in EEPROM |
Posted: Wed Jun 04, 2008 1:07 am |
|
|
Dear sir,
Here i am using 16f913 device, & compiler 4.073 v
So if i want to store numbers < 255 I have to allocate 1 byte of EEPROM.
Then if i want to store number 60000 or above how much byte i have to allocate to store this number in EEPROM.
Because 1 location will store 1 byte of data,so data range is 0 to 255
& if i am using 2nd location data range is 256 to 512 or till 65535.
please clear my knowledge. _________________ Thank You,
With Best Regards,
Deepak. |
|
|
Ttelmah Guest
|
|
Posted: Wed Jun 04, 2008 2:13 am |
|
|
Look in the help file. Contents - Data definitions - Basic types. What does it show that you can hold in an unsigned int16?.
Now do a search here, and you will find lots of threads about how to store these larger types (particularly about floats, but the same answers apply for int16), into the EEPROM.
Hopefully, you can find what you need from these sources. Come back if you have trouble.
Best Wishes |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Jun 04, 2008 2:19 am |
|
|
I wonder how many people will have ignored this question. This is basic progamming knowledge you should already know.
Basically it is the number of bits that determin the size of the value you can store.
8 bits (1 byte) = 0 to 255
16 bits (2 bytes) = 0 to 65535
32 bits (4 bytes) = 0 to 4294967295
basically 2^bits is the size but the range is 0 to (2^bits - 1)
2^8 = 256 but 0 is counted as 1 so you can store a value from 0 to 255.
Hope this helps. |
|
|
deepakomanna
Joined: 06 Mar 2007 Posts: 92 Location: Pune,India
|
byte allocation in EEPROM |
Posted: Wed Jun 04, 2008 3:10 am |
|
|
Actually my question is,
If i want store number at "00 location" max number is 255,OK
& if i want to store number at " 00 & 01 location" max number can be possible is " 512 or 65535." _________________ Thank You,
With Best Regards,
Deepak. |
|
|
Ttelmah Guest
|
|
Posted: Wed Jun 04, 2008 3:23 am |
|
|
Your question has already been answered.....
As Wayne says, it is very 'basic', which is why I said 'read the manual'....
He has put the answer in his reply.
Think of it like a calculator display. If somebody said 'my calculator can display 8 digits, what is the biggest number it can display', the reply would be 'count them'. Mathematically, the answer is (10^8)-1. This is exactly how it works with binary values (and the bytes normally used to hold them). (2^NumberOfbits)-1.
Best Wishes |
|
|
|