Slot and Run commands with external EEPROM

vshortt

Senior Member
This is a theoretical question.

I know that there are 4 program slots on a 28x2. Slot 0 is the default. I also know that you can store additional programs on a memory chip (24LC512, lets say) and then run them using the i2c bus.

The problem is that when you do this, the i2c bus is "locked down" and can only be used to read and run the remote program. If you have other i2c devices, they cannot be accessed while this program is running. So, my question is this:

So here's the scenario:
slot 0 contains the "main" program that always run when you power the device up (think LCD, LED display manager)
slot 1 contains a program to make variable changes (think setup program)
slot 2 contains a program that will go through 6 or 7 different sensors and record data into EPROM #1
slot 3 is what I'm calling a "cratch" slot. It doesn't contain a 'fixed' program.

on EPROM #2, there are 4more slots (or more, with a 512, yes. I know)

slot 0 on eprom #2 contains a program to modify something
slot 1 on eprom #2 contains a program to calibrate sensors
slot 2 on eprom #2 contains a program that is essentially a keyboard manager.
slot 3 on eprom #2 contains a some other program...
and so on...

using this configuration, would it be possible to (from the 'main' program lets say) read the program in slot 0 of EPROM 2, and put it into slot 3 of the picaxe using the i2c bus. Then run slot3 on the picaxe, thereby releasing the i2c bus for use with other devices (sensors, clock etc..).

Essentially, you're re-programming slot 3 on the picaxe when you need to run a remote program.

is there a way to do this?
 

nick12ab

Senior Member
See the BOOTI2C command... but it isn't very good as the internal slot copied to from an external slot is fixed as external slot - 4 so you'd need to have multiple EEPROMS and control the program used by connecting different ones to the i2c bus using some sort of electronic switching or controlling the EEPROM address pins.
 

vshortt

Senior Member
Yeah, that just won't work. Unfortunatley, I need to run programs from several slots, not just slot 4. the clunky option of connecting and disconnecting chips from the i2c bus won't work.
 

nick12ab

Senior Member
Have you tried seeing what happens if you try to access another i2c EEPROM while running the program from an external slot? Since reading the tokens and executing them can't happen at the same time, the i2c bus should theoretically be freed up. You might need to use the i2csetup command after each access command since the PICAXE might not automatically go back to the right EEPROM but test without first!
 

vshortt

Senior Member
You would think so, but the moment you execute the 'run' command on an external slot, all i2c commands are ignored. The only way to re-enable them is to issue another run command using an internal slot.
 

nick12ab

Senior Member
You would think so, but the moment you execute the 'run' command on an external slot, all i2c commands are ignored. The only way to re-enable them is to issue another run command using an internal slot.
Did you TEST that in four minutes or is that just what the PICAXE Manual says? I'm sorry if I'm sounding mean but I don't know what original research (experiments) you have done yourself.
 

vshortt

Senior Member
It's been tested. It was actually tested before I posted. like you, I'm often skeptical of the information given in the manuals.
 

Jamster

Senior Member
If you have internal slot 3 programmed with something like this:
Code:
'b0 is the Procedure to goto
'b1 it the slot to return to
branch b0,(retrivedata, putdata, gettime)
retrivedata:
'Gets data
run b1
putdata:
'adds sdata
run b1
gettime:
'Gets time
run b1
Then by leaving a value in b0 you can tell the PICAXE to do something then return to the slot specified at b1.
You would leave a variable telling the PICAXE where to return to in the program that called this routine as well but I excluded that.

May help,
Jamster
 

Technical

Technical Support
Staff member
booti2c will copy an external program to an internal slot, based upon #revision value.

So if you hack the #revision value (POKESFR $0E,n) within a slot to a lower number, you can fool the chip into running booti2c again, even if it has already been used.
So with a little thought you can get any of the 4 internal slots to be replaced by any of the 4 eeprom slots, by using the poke and then booti2c.

You can have up to 32 external slots, 8 for each internal slot, by using 8 EEPROMS with 8 different addresses. So you could have up to 8 programs for your slot 3 replacement, and update the internal slot 3 to any of these 8 by using the appropriate booti2c command. The only requirement is a separate EEPROM for each of the externally stored slot 3 replacements.

Not for the feint hearted... and the AXE111 EEPROM upgrade board may be of use!


 

nick12ab

Senior Member
based upon #revision value.
Are you sure about that? I tried it with a 40X2-5v last year and although it says that 0 and 255 aren't valid revision numbers in the manual, with no EEPROM connected it'll overwrite the program with a blank program.
 
Top