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

UART > i2c EEPROM

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



Joined: 01 Feb 2012
Posts: 63

View user's profile Send private message

UART > i2c EEPROM
PostPosted: Sun Mar 11, 2012 6:55 pm     Reply with quote

Hello. I`m trying to make a PIC 18F25K22 take the data from UART and write it to a external 24lc1025 EEPROM. I use a ring buffer from the EX_SISR.C example file to store the rs232 data , but i cannot understand how to take that relativly big buffer and write it in the eeprom. I had succeed to write and read a 8 bit value from it with the read_ext_eeprom and write_ext_eeprom commands...but now I`m stuck..also i have a question regarding the incrementing of the address of the eeprom..meaning ..after i reset power my program will know where is the next location to write ( i dont want to overwrite my old data by writing again from 0x00)...a application sample or something regarding these two problems will be very very helpful..thank you forum!
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Mar 11, 2012 7:21 pm     Reply with quote

As far as transferring the data from RAM (buffer) to EEPROM (external storage), check the EEPROM datasheet and see if there's a 'bulk' or 'block' write mode, most do. Eg: writing 256 bytes or more at one time.This will decrease the number and time required to write all the data.

You're the programmer, so it's up to you to keep track of the contents of the EEPROM, and how it's done is up to you. Some use the first few bytes of external EEPROM to store the 'last address used'. How many bytes depends upon size of the eeprom. If the data doesn't get altered much, you could use the PICs internal EEPROM to hold the 'last address used' data. Be careful though as it has limited read/write cycles, check the datasheet, do the math before you destroy the PIC. If you have an external RTC(like the DS1307) with battery backup, you can also use the NVRAM of the RTC to store the data.
There's 3 choices..each has 'pros and cons'..you'll have to decide which is best for your application.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Mon Mar 12, 2012 3:03 am     Reply with quote

Seriously, also consider using an FRAM, rather than an EEPROM. If you use single character writes, at 9600bps, typically four characters could arrive in the time taken to write one byte!. Fortunately multi byte writing would 'help' here, but you could still run into timing issues.

Best Wishes
maria100



Joined: 01 Feb 2012
Posts: 63

View user's profile Send private message

PostPosted: Mon Mar 12, 2012 4:22 am     Reply with quote

I have check out the FRAM, but is not a solution for my project. Does CCS provide some library for multi-byte writing to 24c1025? Because I did not find something like this.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Mar 12, 2012 12:10 pm     Reply with quote

That EEPROM has a 'page mode' of 128 bytes which allows you to send it 128 bytes of data, then issue a single write. It is explained in the datasheet and is a common method of saving data.
Depending on what you're using this data for, you might consider a Vinculum USB flashdrive module. They're about $20, simple fast serial communication, 'unlimited' data storage, and easily read from any PC that has USB ports.
If your project is some kind of 'data logger', it could easily suit you very well.
asmboy



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

View user's profile Send private message AIM Address

PostPosted: Tue Mar 13, 2012 4:28 pm     Reply with quote

I would second TTELMAH s comments RE: FRAM - and having sampled
parts for a design - attest to its speed. EEPROM is always less fun to use than you think, particularly when you have bursts of data to write AND not enough PIC RAM to build a page_write.

Only TWO things you may discover of a negative nature - ::

1- your BOM will suffer a very serious hit to the $$ / unit column.
2- you are facing a sole source vendor issue.

ESPECIALLY true re $$ - if you need 5V operation - in the 1mb size and above.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Mar 13, 2012 5:07 pm     Reply with quote

#3..I think all FRAM devices are SMT !! Too small for my eyes to see to solder ! I checked some months ago....so I might be wrong..

That was another reason why I went to Vinculum modules, I can see them !!
Also good for 5 volt systems...
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Wed Mar 14, 2012 2:56 am     Reply with quote

There are DIL versions available, in a few types (unfortunately, getting fewer), and some parts are multi source. Fujitsu makes some as well as RamTron. A couple of third parties also offer some of the SM parts on DIL carriers. DIL versions are getting rarer and rarer. This is true for other memory types as well though....

Best Wishes
maria100



Joined: 01 Feb 2012
Posts: 63

View user's profile Send private message

PostPosted: Wed Mar 14, 2012 9:06 am     Reply with quote

I have check out Vinculum but didn't understand quite right how they work...can you elaborate a bit?

The primary requirement is that the memory could be a easy to solder package and not too big...like a SSOP 8...Vinculum is quite big...
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Mar 14, 2012 10:16 am     Reply with quote

The Vinculum chips are 'interface' devices allowing any computer to communicate/control any type of USB devices using either SPI or UART style communications. The computer (say a PIC) can be either Host or Slave or even both to the USB devices. Very versitile to say the least!
The 'typical' use is to allow PICs easy, fast, reliable access to flashdrives. NO driver is required, simple commands allow any disk activity(read,write,md,chkdsk,ect).
In my case, the 'PIC based datalogger' stores about 5 years worth of data from many sensors in CSV formatted files. Simply by plugging that drive into PC, Excel opens up the data for instant viewing.
As for size, the chip is about baby fingernail size (check FTDI website). I buy the premade modules with dual USB connectors with either SIP or DIP pinouts. My eyes can't see the SMD packages anymore and I like BIG PCBs, easier to build, test and repair.
It appears you want a fair amount of storage, but to what purpose? If just for the PIC, then FRAM or E2PROM may be fine but if you need to transfer the data to say a PC, then Vinculums offer an easy, universal system.
Yes, more money upfront BUT consider R&D labour, programming code, etc. You can easily spend thousands on that or $20 for a Vinculum.
maria100



Joined: 01 Feb 2012
Posts: 63

View user's profile Send private message

PostPosted: Sat Mar 24, 2012 4:38 am     Reply with quote

Hi again, i have successfully solve all my "problems" only have one now. I really dont seem to find on the forum or on the CCS PDF help file how to write a EXTERNAL EEPROM PAGE (24LC1025) , 128 byte at once,so i can get rid of timing issues. Please , an example , a hint...everything..Thank you!
jeremiah



Joined: 20 Jul 2010
Posts: 1354

View user's profile Send private message

PostPosted: Sat Mar 24, 2012 9:22 am     Reply with quote

maria100 wrote:
Hi again, i have successfully solve all my "problems" only have one now. I really dont seem to find on the forum or on the CCS PDF help file how to write a EXTERNAL EEPROM PAGE (24LC1025) , 128 byte at once,so i can get rid of timing issues. Please , an example , a hint...everything..Thank you!


I typically just look at the data sheet. The CCS eeprom drivers write one byte at a time. Look at the difference in the data sheet for one byte versus multiple bytes (they give examples of both). I just use a for loop at the spot that would make sense based on the data sheet. The only thing past that you need to do is manage when you reach a page boundary. You can use modulo math (will be fast because pages are powers of 2) and some basic addition/subtraction to figure out if you are at a page boundary. When you reach a page boundary, you have to stop transmission, and start it up again, UNLESS you are only writing pages, then all you have to worry about is the looping and making sure the write address is on a page boundary.
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