CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Program memory content after erasing

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bejoy_ak



Joined: 20 Jun 2008
Posts: 10

View user's profile Send private message

Program memory content after erasing
PostPosted: Wed Jul 22, 2009 11:29 pm     Reply with quote

Why during erasing 1's are written to pic's program memory? Why not 0's are not written?
Ttelmah
Guest







PostPosted: Thu Jul 23, 2009 2:37 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jul 23, 2009 3:40 am     Reply with quote

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 Smile

Disclaimer: If any of this is incorrect blame someone else Smile Please no flames or derogatory (speelling) remarks Smile
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Jul 23, 2009 5:20 am     Reply with quote

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: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Jul 23, 2009 9:38 am     Reply with quote

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







PostPosted: Thu Jul 23, 2009 9:47 am     Reply with quote

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: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Jul 23, 2009 4:21 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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