Keep cog running but restart main program?
simonl
Posts: 866
Spurred on by Beau's latest high-speed comm's code, I have an idea for a persistent communications cog that will allow for data to be written to any part of hub RAM. I envisage this facilitating a new program to be loaded and then run, so I have two questions:
I'm not clever enough to figure this lot out, but is this something similar to what "cogjects" does? (OK, so three questions!)
- Is it possible to kick the new program into life just by writing to a particular location?
- Is it possible to keep the comm's cog running even after the new program's been started?
I'm not clever enough to figure this lot out, but is this something similar to what "cogjects" does? (OK, so three questions!)
Comments
2) Sure. I've written several different I/O drivers that do the same thing. The sdSpiFemto.spin driver in FemtoBasic does this loading from either EEPROM or from an SD card. The Winbond flash driver in the ObEx does this. You can do it too.
Look at the driver in the Winbond object for a relatively clean example. It reads the program in from flash and then starts it up in the driver's cog. All you have to do is change the final COGINIT to a COGNEW (in PASM ... it's a bit in the operand).