Pre-load i2c memory chip from file

bpowell

Senior Member
Hi gang!

Before I go reinventing the wheel... Is there a program already developed to pre-load an i2c memory chip (24lc256) from a text file? I'm thinking of using a terminal program to send to the picaxe at 300 baud... This would give me enough time between bytes to do a page write every 64 bytes without losing anything on the serial line.

I just wanted to see if this had been done before?

I also have a pickit3... but I don't see a way to program the ram with it... But I'm not the sharpest tool in the shed!

Maybe I should dig out a different USB serial adapter and try to use hardware flow control? Am I making this too complicated?

Thanks!
 
Last edited:

bpowell

Senior Member
Thanks Westaust55...

Those links show how to load data via I2C to the eeprom...which makes sense...what I'm looking to do is:

1: Take a text file (it's a snipped from a book)
2: Push that text file onto the 24LC256

So, I'll need to PICAXE to take Serial data from the PC, and flip it to the RAM chip.

I'm concerned even at 300Baud, the timing will be tight allowing a 5ms delay between page-writes.

The third link you posted is something along the lines of what I'm looking for...but requires a custom PC program, and also requires the text to be broken out into a CSV with memory address and then byte.

I think I'll take a look at XON/XOFF flow-control...if I can have the PICAXE stop the data flow at 64 bytes...just long enough to write the page, and give the 256 time to recover, that will be perfect.
 

Dippy

Moderator
If you are writing your own you can send it in blocks with software handshake.
But first things first, what PC software are you going to use to send the serial to the PICAXE?
 

bpowell

Senior Member
Hi Dippy,

I'm okay with writing my own PICAXE software...I'm not too savvy with PC software...my plan is to use GTKTerm on Ubuntu...it has support for software flow-control, and you can select "Send raw file" which is my plan.

Currently, I'm thinking something along the line of:

Pseudo-code:

Counter = 0
Receive serial byte
Forward serial byte to I2C RAM
Counter ++
If Counter = 64
Send XOFF (hex 13)
Send "Write page" to I2C RAM
Pause 5ms
Send XON (hex 11)
Back to top


That's my plan at least...I like to have a plan first, because it's fun to watch it all fall apart! :)
 

AllyCat

Senior Member
Hi,

Which PICaxe are you planning to use? The X2 family have background receive and I would think could go much faster.

But even with an M2, are you sure you've got your maths correct? AFAIK, at 300 baud (33 ms/byte including start/stop) a 64 byte page write will only occur after more than 2 seconds and it will be at least 30 ms before there is even one more byte to write to the I2C bus.

Of course there may well be "issues" with the limited time available to write to the I2C hardware between bytes received using the PICaxe's software SERIN or SERRXD. For that reason I have recently been looking at using HSERIN with the M2s and may have something to post soon. ;)

Cheers, Alan.
 

hippy

Ex-Staff (retired)
my plan is to use GTKTerm on Ubuntu...it has support for software flow-control, and you can select "Send raw file" which is my plan.
The problem with relying on X-ON/X-OFF flow control is that some bytes may still get sent after the X-OFF is sent.

That may be acceptable if using background serial receive but the usual solution is a custom PC program which sends a fixed size block of data then waits to be told it can send some more. If you use background serial receive on the receiving PICAXE you can have a block size up to the size of the background serial buffer. If using SERIN then it's often easiest to just send one byte at a time though it might be possible to receive more bytes per SERIN command.
 
Hi bpowell,

I had a similar problem which may have some relevance to your application. If you can paste your text file into EXCEL (or a similar spreadsheet), then you may be able to use the LEFT, MID and RIGHT EXCEL commands to parse the data. You can then add commas, brackets and text such as “writei2c”, “pause” etc. Copy this part of the spreadsheet and paste it into the PICAXE editor and run it to load the data into the EEPROM. Then re-load the program that uses the data.

In my application, I needed to load 300 eight-digit numbers, calculated by EXCEL, into 24LC256 for later use by the 40X1 controller and to do that by hand would have been error prone, not to mention boring!

Richard
 
Top