November 9, 2009

Eeprom and Flash Emulated Eeprom

This post talks about some basics of EEPROM and FEE.
To start with the discussion it is necessary to know what EEPROM stands for. EEPROM stands for Electrically Erasable PROM. Where PROM means Programmable Read only memory. The very fact that we are highlighting the Electrically Erasable means that there are other methods to erase the PROM. I leave it to the reader to find out what these are and leave as a comment.
Why do we need it?
In any system there are some set of parameters that need to be remembered through power cycles and can/may change between power cycles. An example....Well Your monitor settings ( i.e. the brightness contrast etc that you do on your monitor) is remembered through power cycles even if you connect the monitor to another PC or whatever. One of the places to store this could be the EEPROM.
What does this mean?
To write to the EEPROM i should be able to erase it and then rewrite it. Also it should be capable of being written several times ( maybe a few lakh times). Also, it should have data retention capacity. i.e if i write it today and check after say some 10 years the data should be same in the absence of any power.
What is FEE then?
As you can see some of the properties of EEPROM are held by the flash memory also. Like i can write into the Flash memory electrically, it can retain information across power cycles, it can be written multiple times. However, the biggest different is that the flash technology ensures that it can be written only in huge chunks like 64 or 128 bytes. Also, the life of the Flash memory is much lesser than the EEPROM. On the other hand the best part is that it costs much less than the EEPROM.
So FEE which stands for Flash Emulated EEPROM is basically a method of emulating the behaviour of the EEPROM using the Flash memory. This means if a Flash memory has 10000 write cyles, i should make it some how work as if it is 100,000 write cycles ( like in case of EEPROM). Also, i should provide somehow the capability of writing a single word/ single byte as available in the EEPROM.
In short if i have FEE then the application should feel as if it is having EEPROM....
How to do this ? Well that is for another post....


Please leave your comment. You can subscribe to this blog by using the links under "Subscribe" section.


Powered by ScribeFire.

October 17, 2009

Sign language

I have been assigned the painful job of taking interview for my team in company. Why is it painful? Because i am the junior interviewer in the panel and I have to put through the bullshit that the senior interviewer gives to the candidate.... Anyway, this post is just about a couple of things i found people where not aware of !!

Signed arithmetic in C?
First thing we should know that most C compilers and µC's use 2's complement method to do signed arithmetic. If you are wondering hey that is the only way....Wait!! Another way of representation is by using the first bit for sign and rest of the data.
Which means
-5 = 0x1101
-7 = 0x1111
This representation is good and simple. However, it was not so good for the chip manufacturers who had a problem with zero.
0 = 0x0000 or 0 = 0x1000. Which meant that on the number line the same number could be represented by two symbols.
This problem was solved by introduction of the 2's complement. Which is nothing but 1's complement + 1.
which means
-5 = 0x1011
-7 = 0x1001 and 0 = 0x0000.
There was no concept of negative zero. This effectively ensured that for n bits one could represent 2^(n) values. So for 4 bits we should have 16 values. 8+tive and 8 negative. However, we have 8 negative -1 to -8 (0x1000). And 7 positive (1-7). Zero is actually neither positive nor negative and takes the middle position (without a sign bit so really it is a positive...what say?).
One question that i sometimes ask is why was 0x1000 not chosen as +8? Technically it is correct!!. There are two problems. 1) we would kill a advantage which we have with 2's complement ( i.e. MSB is 1 if the number is less than zero). 2) I forgot!!...

Anyway, It is necessary that we understand how signed arithmetic works to understand concepts like add through overflow ( used in Targetlink), Usage (or avoiding!!) of saturation blocks ( in Targetlink and RTW). You can do intelligent coding if you understand how the signed numbers are understood by the compiler you are using.

Please leave your comment. You can subscribe to this blog by using the links under "Subscribe" section.


Powered by ScribeFire.