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

EEPROM programming

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



Joined: 01 Sep 2009
Posts: 10
Location: Malaysia

View user's profile Send private message

EEPROM programming
PostPosted: Sat Jan 02, 2010 10:55 pm     Reply with quote

Hello, I have a problem regarding EEPROM programming. I use CCS help section to search the write_eeprom() syntax. I want to know, do I need to set the bits for eeprom such as EEADR or any bits that are required to make eeprom writing work ? Or do I just use the write_eeprom(address,value) ?
_________________
CCS Version: 4.038
Current project: Obstacle detection robot
Ttelmah
Guest







PostPosted: Sun Jan 03, 2010 4:09 am     Reply with quote

Just use write_eeprom.
The function does all the 'donkey work' for you.

This is the basic 'point' about CCS. The supplied functions (RS232, eeprom etc.), 'encapsulate' all the basic operations, so you don't have to worry about how your particular PIC does it. You can take a program written on a PIC16xxx, and provided you only use the standard functions, just change the header (processor include, fuses etc.), and reompile it to run on a PIC18, and it works. Smile

Best Wishes
webgiorgio



Joined: 02 Oct 2009
Posts: 123
Location: Denmark

View user's profile Send private message

PostPosted: Sun Jan 03, 2010 7:14 am     Reply with quote

Code:
write_eeprom(address,value);

Which address have I to use?
I have not understand looking to the datasheet.
I'm using a 16f876a and "value" is an int16.

tnx
Ttelmah
Guest







PostPosted: Sun Jan 03, 2010 8:52 am     Reply with quote

Address, is up to _you_ (within the limitations of the chip).
If your chip has 256 bytes of EEPROM, address, is the number of the location in this you want to use. If you use address=0, the data will be written to the first byte in the EEPROM. Use address=255, and the data will be written to the last byte.
On chips with 1024 bytes of EEPROM, address can be 0 to 1023.
Think of the EEPROM, like a set of numbered pigeon holes. The address, is the number of the pigeon hole to use.

Best Wishes
webgiorgio



Joined: 02 Oct 2009
Posts: 123
Location: Denmark

View user's profile Send private message

PostPosted: Sun Jan 03, 2010 9:42 am     Reply with quote

looks very simple! Smile
Is a byte in the eeprom 8 bit right? so doing write_eeprom(0,value); I will write byte 0 and byte 1, right? (value is int16 type)
kazama



Joined: 01 Sep 2009
Posts: 10
Location: Malaysia

View user's profile Send private message

PostPosted: Sun Jan 03, 2010 10:19 am     Reply with quote

So if I use 16f877a with eeprom data memory 256 bytes.. the range of address is 0 - 255. For the syntax write_eeprom(address,value); the address can be use in hex form or not? eg: write_eeprom(0x00,value);. For the value if I declare the adc as var1 = read_adc(), so the value = var1.. eg: write_eeprom(0x00,var1);. Am I right?

thanks
_________________
CCS Version: 4.038
Current project: Obstacle detection robot
Ttelmah
Guest







PostPosted: Sun Jan 03, 2010 11:21 am     Reply with quote

I think some reading on basic C, and numeric formats is needed....

Numbers inside the chip, are always _binary_ (nothing else). C handles automatically converting decimal, octal, or hex to this for you.

A 'byte' is always 8 bits.
Bit beans 'binary digit'. One digit of a binary value. A 'nibble' is four bits, and a byte is 8 bits.

Best Wishes
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