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 CCS Technical Support

EEPROM 8-bit or 16-bit?

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



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

EEPROM 8-bit or 16-bit?
PostPosted: Wed Apr 08, 2015 3:37 pm     Reply with quote

I've been trying devices in the 24-bit opcode world...

On the 30F6014A, I have access to 4K of internal EEPROM.

I'm writing a function to write and read unsigned int32 directly to the EEPROM.

However from the CCS help file it's not very clear what type of int I expect to receive.

Quote:

Relevant Functions:


(8 bit or 16 bit depending on the device)


read_eeprom(address)
Reads the data EEPROM memory location



write_eeprom(address, value)
Erases and writes value to data EEPROM location address.



read_eeprom(address, [N])
Reads N bytes of data EEPROM starting at memory location address. The maximum return size is int64.

read_eeprom(address, [variable])
Reads from EEPROM to fill variable starting at address

read_eeprom(address, pointer, N)
Reads N bytes, starting at address, to pointer

write_eeprom(address, value)
Writes value to EEPROM address

write_eeprom(address, pointer, N)
Writes N bytes to address from pointer



Microchip datasheet talk about transferring data per chunk of words (so int16 right?)

I've always dealt with writes one byte at time on the PIC16/18 series.
_________________
Regards,
Laurent

-----------
Here's my first visual theme for the CCS C Compiler. Enjoy!
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Apr 08, 2015 5:38 pm     Reply with quote

although the 30F part in question can allow values less than 16 bits - for the purposes of the data sheet, a WORD for the EEPROM is still 16 bits ....

So what do you think when you read page 57 of the datasheet?
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Apr 08, 2015 10:29 pm     Reply with quote

Ultimately, it comes down to the datasize of the storage medium.

YES, you are still writing bytes.

One method I like it to put my entire config into a structure.

This can be a mix of anything. uint8, int16, floats, doesn't matter.

then I create a pointer to the structure when saving and step through the bytes of the struct and save/load them to/from the EEPROM/Flash.

Works swell.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Thu Apr 09, 2015 1:14 am     Reply with quote

The EEPROM functions on the 30F chips read and write 16bit words, not bytes.

If you look at the example. ex_intee.c, you will see them simply test for the compiler version:
Code:

#if defined(__PCD__)
 // dsPIC30F/dsPIC33F/PIC24 internal eeprom is 16bit wide
 typedef int16 INTEE;
#else
 typedef int8 INTEE;
#endif


and they then declare the value they are reading and writing as "INTEE value".

The manual is wrong, in that while it says that 'read_eeprom' returns either 8 or 16bit, on the write_eeprom function, it says that the value is 8bit. However it isn't. The function writes 16bit lumps on these larger PIC's.

So:
Code:

void weeprom(unsigned int16 addr, unsigned int16 val)
{
  write_eeprom(addr,val); 
}


Writes a 16bit value to the EEPROM.
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