Bits and bytes lesson

jmumby

Senior Member
Hi,

Please digest the following....

The AT24C128/256 provides 131,072/262,144 bits of serial electrically erasable and
programmable read only memory (EEPROM) organized as 16,384/32,768 words of 8
bits each.

I don't understand. Why does does my 24c128 have 256bytes? Why don't they just say the chip holds 256Bytes!
 

Dippy

Moderator
I haven't studied in detail but i think you've misread.
Having said that, Data Sheets can sometimes be written a little 'briefly' and often list things 'repesctively'.

If you convert the shorthand.
"The AT24C128/256 provides 131,072/262,144 bits of serial electrically erasable and
programmable read only memory (EEPROM) organized as 16,384/32,768 words of 8
bits each"

This equals:
The AT24C128 provides 131,072 and the AT24C256 provides 262,144 bits
ditto...
organsised as 16,384 words for 128 , and organised as 32,768 for AT24C words of 8
bits each

The authors often use a "/" to make respective lists in Data Sheets. Happens a lot with dervative lists like op-amps too.

You just need to keep an eye out for this.

So, "Why does does my 24c128 have 256bytes?" (..or even 256KBytes)
- it doesn't.

" Why don't they just say the chip holds 256Bytes!"
- dunno, tell me :) (kidding btw, convention maybe brought forward from olden days? using the divide button on your calc ain't so difficult eh?)
 
Last edited:

jmumby

Senior Member
Why is the sky blue?

Here is the data sheet http://www.datasheetcatalog.org/datasheets/228/160402_DS.pdf.

I created a loop to write 0x00 to 0xFF and it fills the eeprom and will start again (as it says it will in the datasheet). I would like to know and how many I should devide by to get to 256bytes. It doesn't really matter I guess cause at the end of the day I'm gonna write 256bytes regardless.

I hate the 'just because' aspect of these things. Knowing why would provide some relief.

Also it says that the words are 8 bits.....shouldn't they be 4 bytes??
 

hippy

Technical Support
Staff member
Looking at my datasheet it says, "provides 131,072/262,144 bits ... organized as 16,384/32,768 words of 8 bits each", and "128K (16,384 x 8), 256K (32,768 x 8)"

www.atmel.com/atmel/acrobat/doc0670.pdf

Hardware manufacturers of memory products tend to describe their products in terms of capacity measured by the number of bits available. This appears to be their convention and is fairly standardised. The number at the end of the device name usually reflects this, eg AT24C128 = 128K, that is 128K bits.

At least the using of a standardised unit of capacity (bits) makes it easy to compare capacities of various components without the confusion of which is larger; 128Kb or 64KB, having to read further to determine if "Kb" or "KB" is used to mean bits or bytes.

An AT24C128 has 131,072 bits (128Kb), 16,384 x 8 (16KB)

An AT24C256 has 262,144 bits (256Kb), 32,768 x 8 (32KB)

As to the use of "word"; this was originally a generic term for a unit of memory of some bit-width and is still used that way in many cases. It is not necessarily 16-bits ( 2 bytes ) or 32-bit ( 4 bytes ).

While "byte" is more universally taken to be 8-bits, by not using the term in the datasheet it avoids confusion and complaint where a byte is not considered to be 8-bits. It is however fairly easy to convert between the units manufacturers use and what programmers usually use -

Number of bytes = Number of bits / 8

Number of K bytes (KB) = Number of bytes / 1024

Number of K bytes (KB) = Number of bits / 8192

Also note that "K" when used by programmers and hardware manufacturers is usually taken to be 1024 ( 2 to the power 10 ) , in some cases, particularly for disk and removable storage ( SD Card etc ), it can mean a decimal 1,000.
 
Last edited:

Dippy

Moderator
I agree that some of these 'conventions' can be a pain arithmetically.

I'm now confused by your question. (I thought you'd dropped a "k" accidentally).
You seem to be saying that your 16Kb chip only holds 256 bytes.
Can't see how you worked that out.

But, in practice, if you are only writing/reading 256 Bytes then there is no problem.

"I would like to know and how many I should devide by to get to 256bytes"
- why? I really don't understand, sorry. Surely you will be writing bytes consecutviely? So, you will be using 256 out of 16384. Where is the problem?

"Also it says that the words are 8 bits.....shouldn't they be 4 bytes??"

-You obviously know from where the word (no pun) "byte" is supposed to have derived?
(Without Googling :))
Most baby uPs refer to "words" as 2 bytes, though I agree it can be a bit (no pun) variable universally.
Hence, if you know the number of bits etc. you can work it out for yourself. For larger data blocks any page/buffer sizes will be required.
If you just stick with bits and bytes its a lot easier, and then, as you know the compiler's definition of "word" length then you will be a happy chappy.
 

westaust55

Moderator
Believe the "issue" is he has a 128 kbit = 16kbyte serial EEPROM and thinks that it will hold 256 kbits = 32kbytes of data.

but the real point is that after 16kbytes, the location rolls over back to the start.

While the EEPROM memory location uses 2 bytes (= 16 bits) for the memory address, on page 8 the full story is exposed.
bit 15 = * and bit 14 = †

and further down the same page are the notes:
(* = DON’T CARE bit)
(† = DON’T CARE bit for the 128k)

So while jmumby is sending out 15 or 16 bits address data when it gets to 16kbytes the internal memory locations just rolls over.
(Much the same applies with the 64-byte page addressing scheme)

@jmumby,
try writing say $55 in all the lcoations as you did before,
then write $AA in the first 16kbytes and check the next byte (location 32768).
You should find it is already $AA (unless you really have a 32kbyte EEPROM).
 

ylp88

Senior Member
-You obviously know from where the word (no pun) "byte" is supposed to have derived?
(Without Googling :) )
And it should be obvious where the word nibble (or nybble) is derived from :D
(again no Googling) :eek:
It makes me hungry thinking about it... On that note, I did have a look at the Wiki entry and quite enjoyed the section entitled Alternative words, especially those for two bits!

ylp88
 
Top