Query about ROMBuffer WRITE

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Francis
Registered User
Registered User
Posts: 314
Joined: Sun Mar 25, 2007 9:40 am
Location: Devon

Query about ROMBuffer WRITE

Post by Francis » Wed Feb 24, 2010 3:58 pm

I'm just trying to get my head around the ROMBuffer routine.

Example.
Supposing I have some code where a few small 'files' are sent from a PC via Serial to PIC and stored using ROM.writebyte.
Then retrieved later on in PIC code.

Essentially I'm hoping to replace an EEPROM as i have plenty of space on PIC.

Q1. Assuming these 'files' (simple blocks of data bytes) are to be sent in separate lumps, how do I tell ROM.writebyte to start at a particular location?
i.e. for writing; Set Start location .... ROM.Write the Byte... repeat..


I can follow it for reading back i.e. set the index and go on from there, BUT I can't understand the ROM.Write.
In the example:

Code: Select all

// write values to ROM...
ROM.BeginWrite
For Index = 0 To ROMBufferSize - 1
   ROM.WriteByte(Index)
Next
ROM.EndWrite
- is 'Index' the Flash destination location where the byte/block will be written?
If so, where do I specify the byte(s) to be written?
No variable for the data byte is apparent.
e.g. if I have byte variable Fred=12 how do I send that to locationX using ROM.Writebyte ?

Is 'Index' an arbitrary value or an absolute value?
(If absolute, where do I find a safe 'start' point after code?)



One final thing, I notice in Proton 'Help' for CWrite it says that "WRTE_ON fuse setting must be included" - is a similar thing needed in SF ?

Any suggestions/prompting/kicking greatly appreciated :?

Jerry Messina
Swordfish Developer
Posts: 1471
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Post by Jerry Messina » Wed Feb 24, 2010 7:19 pm

The example shown is a bit confusing, as it's writing the "index" value as the data. You don't directly control the write index.

The index is set to 0 in the ROM.BeginWrite routine (which also erases the entire buffer),
and you call ROM.WriteByte(value_to_write) and it writes the data sequentially starting at index 0.

The module is geared more to "write all or nothing" rather than a general EEPROM replacement.

Francis
Registered User
Registered User
Posts: 314
Joined: Sun Mar 25, 2007 9:40 am
Location: Devon

Post by Francis » Wed Feb 24, 2010 8:46 pm

Thanks Jerry.... so close.... :cry:

Post Reply