How to reset P2
David Betz
Posts: 14,526
How do I cause the P2 to reboot programmatically? I'm working on code to boot a large program from flash and I'd like to force a reboot after writing the flash. What's the best way to cause the P2 to reboot?

Comments
CON SERIAL_TX = 90 ' serial pins SERIAL_RX = 91 DAT coginit monitor_pgm, monitor_ptr 'relaunch cog0 with monitor monitor_pgm long $55C+$1B4 'monitor program address monitor_ptr long SERIAL_TX<<9 + SERIAL_RX 'monitor parameter (conveys pins)When a COG is started, $1F8 contiguous longs are read from HUB memory and written to COG registers $000..$1F7. The COG will then begin execution at $000. This process takes 1,016 clocks. Example: COGID COGNUM 'what COG am I? SETCOG COGNUM 'set my COG number COGINIT COGPGM,COGPTR 'restart me with the ROM Monitor COGPGM LONG $0070C 'address of the ROM Monitor COGPTR LONG 90<<9 + 91 'tx = P90, rx = P91 COGNUM RES 1 'If you want to inspect hub memory after your program has run, ' just put the following code at the end of your program: Code: coginit monitor_pgm,monitor_ptr 'relaunch cog0 with monitor monitor_pgm long $70C 'monitor program address monitor_ptr long 90<<9 + 91 'monitor parameter (conveys tx/rx pins) 'This will launch the ROM Monitor and let you view what your program did to hub memory. ' The monitor only affects the hub memory when you give it a command to do so. So, when ' the monitor starts up, hub memory is just as your program left it, ready to be inspected.That example come from Chip.
In dump that address starts with Long - 0
But I have not looked yet why Chip starts at this point.
_________ CLKSET D --------- CLKSET writes the lower 9 bits of D to the HUB clock register: %R_MMMM_XX_SS R = 1 for hardware reset, 0 for continued operation MMMM = PLL multiplying factor for XI pin input: % 0000 for PLL disabled % 0001..% 1111 for 2..16 multiply (XX must be set for XI input or XI/XO crystal oscillator) MMMM = PLL mode: % 0000 for disabled, else XX must be set for XI input or XI/XO crystal oscillator % 0001 for multiply XI by 2 % 0010 for multiply XI by 3 % 0011 for multiply XI by 4 % 0100 for multiply XI by 5 % 0101 for multiply XI by 6 % 0110 for multiply XI by 7 % 0111 for multiply XI by 8 % 1000 for multiply XI by 9 % 1001 for multiply XI by 10 % 1010 for multiply XI by 11 % 1011 for multiply XI by 12 % 1100 for multiply XI by 13 % 1101 for multiply XI by 14 % 1110 for multiply XI by 15 % 1111 for multiply XI by 16 XX = XI/XO pin mode: 00 for XI reads low, XO floats 01 for XI input, XO floats 10 for XI/XO crystal oscillator with 15pF internal loading and 1M-ohm feedback 11 for XI/XO crystal oscillator with 30pF internal loading and 1M-ohm feedback SS = Clock selector: 00 for RCFAST (~20MHz) 01 for RCSLOW (~20KHz) 10 for XTAL (10MHz-20MHz) 11 for PLLThanks again! I guess I wouldn't have thought of using CLKSET to do a reset. From what you list it sounds like this will reset the P2: Does that sound right?
Sorry, I guess it has to be this:
mov t1, #0x100 'hardware reset clkset t1Anyway, CLKSET works fine and so does my flash loader test! Thanks!!
In Yours example You will reset it to
>
Because the the clock register is cleared to % 0_0000_00_00 on reset, the chip starts up in RCFAST mode
with both the crystal oscillator and the PLL disabled.
You need in same time set other value3s to what You want.
I've pushed the propeller-load changes. You can now use the propeller-load -e option to write a program to the flash and have it boot on reset. We still don't have support for XMM mode yet though so you're limited to COG, LMM, or CMM programs at the moment. However, your LMM or CMM program can use all of the 126k of hub memory.