Page 1 of 1

EEPROM memory map quest and I2C tips

Posted: Fri Jan 11, 2019 5:47 am
by paulsoulsby
I'm writing to the ext EEPROM via an Arduino. Got a question about the memory map and couple of tips that I've found out, that I couldn't find on the forum.
:?: I'm assuming that each patch is 512 bytes and layout out sequentially across the EEPROM. Is it safe to assume any patch starting with 0x80 is a patch and any other value is blank? (assuming EEPROM is flashed with value hex).

:arrow: I2C frequency is 262144Hz (a multiple of the spin clock)
:arrow: The EEPROM takes up to 5ms to write to, regardless of whether you write 1 byte or a page (32 bytes). The I2C bus mustn't be accessed during this time or you will get errors. Therefore it makes sense to write patches to EEPROM in pages of 32 bytes for a 32x speed increase!
:arrow: Here's some simple Arduino code to do this:

Code: Select all

	
	#define EEPROM_SIZE 4096
	#define EEPROM_ADDRESS 0x50
	#define EEPROM_PAGE_SIZE 32
	#define EEPROM_PAGES (EEPROM_SIZE / EEPROM_PAGE_SIZE)
	uint16_t addr = 0;
	Wire.begin();
	Wire.setClock(262144);
	for (uint8_t i=0;i<EEPROM_PAGES;++i)
	{
		Wire.beginTransmission(EEPROM_ADDRESS);
		Wire.write(addr >> 8); // MSB
		Wire.write(addr & 0xFF); // LSB
		for (uint8_t j=0;j<EEPROM_PAGE_SIZE;++j)
		{
			Wire.write(pgm_read_byte(&(SPIN_EEPROM[addr])));
			addr++;
		}
		Wire.endTransmission();
		delay(5);  //time for page write
	}
:arrow: You can use Hex2Bin to convert a SpinASM hex file to binary data: https://sourceforge.net/projects/hex2bi ... 2/download

Re: EEPROM memory map quest and I2C tips

Posted: Fri Jan 11, 2019 1:05 pm
by igorp
"it safe to assume any patch starting with 0x80" - never assume this
patch can start with any of commands+data. Use address offset. Patch#0 = offset 0 , Patch#1 = 0x200 , Patch#n = n*0x200

if You need compression - use popular compressors, or kind of RLE.
I did kind frequency compressor (FV-1 uses 20 or 23 commands of 32 possible, so "fake" commands 24 to 31 and other 3 bits can be used for replacement of popular commands by dictionary), may be will publish it later

Re: EEPROM memory map quest and I2C tips

Posted: Mon Jan 14, 2019 7:31 am
by paulsoulsby
Thanks for reply - I think I phrased the question poorly. What I meant was:
:?: how many bytes of a patch do I need to read, to know that it is blank. E.g. just first byte or full 32 byte page etc?
When you create a hex file in SpinASM some patches can be blank, so I only want to write the patches that contain data to the EEPROM.

Re: EEPROM memory map quest and I2C tips

Posted: Tue Jan 15, 2019 11:17 am
by igorp
1. Patches are going one after another in spin asm project. So, if you have no empty slots in project, you will have no empty patches in hex file.
2. fully empty patch contain {0x11 , 0 ,0 , 0} x128 times .
3. Not programmed area on the flash chip usually contains all 0xFF

Re: EEPROM memory map quest and I2C tips

Posted: Thu Jan 17, 2019 11:43 am
by frotaitalos
Hi everyone, I also want to record an external eeprom with arduino, but my knowledge is minimal on this subject, looking at the code above where will I put the binary for the arduino to record in eeprom?

Re: EEPROM memory map quest and I2C tips

Posted: Wed Apr 10, 2019 2:32 pm
by DrAlx
I used an Arduino program to write FV-1 programs to EEPROM as part of a DIY project.
The EEPROM burner is part of the zip file here

https://1drv.ms/u/s!AvrH61utWEtEinTuwzdgxpn2TVm8