Hi Shaun,
there is little bit different problem. In S32 Design Studio startup, there is disable watchdog code at the very beginning of this file. But at the moment you try to disable watchdog, MMU is not initialized, so you are not able to access the SWT addresses. This is the cause of your issue.
When you load the code to the microcontroller via debug probe (PE Micro debug probe), this probe place you to the start of the main function at first. But when you reset the microcontroller, it starts to execute instructions from entry point, which is 0x1000. Now MMU is not configured and only addresses from range 0x1000 to 0x1FFF are accessible. MMU configuration is the part of the startup.
So the solution is following. Delete the SWT disable code from startup (or delete the symbol DISABLE_SWT from project properties) and place the following function to your code, or change the order of MMU inititialization and disable watchdog code in the startup file. MMU initialization has to be done before disabling watchdog.
void DisableWatchdog(void)
{
SWT.SR.R = 0x0000c520; /* Write keys to clear soft lock bit */
SWT.SR.R = 0x0000d928;
SWT.CR.R = 0x8000010A; /* Clear watchdog enable (WEN) */
/* e200 Core Watchdog Timer */
asm("e_li %r3, 0");
asm ("mtspr 340, %r3");
}
Call this function in the very beginning of your main function. Now it should work correct.
Please let me know, if it is OK on your side.
Regards,
Martin