View previous topic :: View next topic |
Author |
Message |
bejoy_ak
Joined: 20 Jun 2008 Posts: 10
|
Program memory content after erasing |
Posted: Wed Jul 22, 2009 11:29 pm |
|
|
Why during erasing 1's are written to pic's program memory? Why not 0's are not written? |
|
|
Ttelmah Guest
|
|
Posted: Thu Jul 23, 2009 2:37 am |
|
|
Nothing is 'writen'. It is just that erasing gives a '1'.
It is a bit like why does a 'blackboard' 'erase' to black, while a 'whiteboard' erases to white?.
It is down to what type of memory 'cell' is used in the hardware.
Best Wishes |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Thu Jul 23, 2009 3:40 am |
|
|
Although Ttelmah is technically correct there is another reason.
Some devices (Flash) require alot more effort in changing a bit from 0 to 1 but changing a 1 to a 0 is easy. Either a complete erase or slower page erases are required and usually it is not possible to set the bits of an individual byte to 1 without an erase.
This becomes important when you look at the number of erase cycles a flash device can handle, it is not infinate. To reduce the number of erases you can write your code so that if you are changing a byte and you only need to swap bits in the curent value from 1 to 0 you can just overwrite that memory location e.g.
addr1 = 0xFF (0b11111111 erased)
you can directly change any of the bits to 0 so you can write any value
addr1 = 0x77 (0b01110111)
You can now write any value to this location which only changes the bit from 1 to 0 without an erase
addr1 = 0x03 (0b00000011)
Why you can change a bit from 1 to 0 with a write and need an erase to change from 0 to 1 is proberbly down to the physical design of the chip. Basically I don't know without looking it up
Disclaimer: If any of this is incorrect blame someone else Please no flames or derogatory (speelling) remarks |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Jul 23, 2009 5:20 am |
|
|
Of course, the assignment of logical "1" to erased state is arbitray. But it's a common standard for all programmable memories since decades, also expected by any tool dealing with memory contents. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu Jul 23, 2009 9:38 am |
|
|
it's a good idea since a blown device might return all 0's while a working device that's erased would return 1's.
I think the 1 vs 0 is also based on the type of cell. I read about it someplace but have forgotten the details.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
Ttelmah Guest
|
|
Posted: Thu Jul 23, 2009 9:47 am |
|
|
Basically, it is historical, since there is nothing to stop you adding an inverter after the cell. On the early EEPROMs, erase was done using UV, rather than electically, which 'set' which way the charge had to go in the cell, and most electrical designs, have kept to the same standard.
Best Wishes |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Thu Jul 23, 2009 4:21 pm |
|
|
Ttelmah wrote: | Basically, it is historical, since there is nothing to stop you adding an inverter after the cell. On the early EEPROMs, erase was done using UV, rather than electically, which 'set' which way the charge had to go in the cell, and most electrical designs, have kept to the same standard.
|
Right - I remember the UV thing...
I didn't find any direct reference though. (shrug)
Moving along... :D _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
|